Under construction

Still being built. Things may change

Malatang Tanghulu (hard)

Time limit2sMemory limit1024 MB

Summary
Decide whether inserting P strawberries and Q grapes per minute can equalize every skewer's counts, and output the insert counts if so.
Level

Medium6 of 10

Topics
Number theory, Math, Implementation
Solved
No attempts yet

Problem

그럼 제가 선배 맘에

<서이브/남동현, 마라탕후루, 2024>

Chito, the mascot of Ajou University, opened a malatang tanghulu shop by combining malatang and tanghulu, two snacks that are popular these days. On the first day, however, a wrong order left boxes of strawberries and Shine Muscat grapes piled up. Fruit has to be fresh, so today Chito decided to give tanghulu to customers for free.

Chito made NN tanghulu skewers in advance. While busy, Chito stuck fruit on whatever was at hand, and only later realized that the number of strawberries and Shine Muscat grapes on each skewer could differ. To keep the flavor balanced, each skewer must have the same number of strawberries and Shine Muscat grapes. However, different skewers do not need to have the same count as each other. Chito hired a robot to even out the counts of strawberries and grapes, because the shop is too busy for that.

Skewer ii currently has AiA_{i} strawberries and BiB_{i} Shine Muscat grapes. The robot has one flaw: it always inserts a fixed number of each fruit at a time. Every minute, the robot performs the following action once.

  • Choose skewer ii and skewer jj. Here ii and jj may be the same. (1≤i,j≤N)(1 \leq i, j \leq N)
  • Insert PP strawberries into skewer ii and QQ Shine Muscat grapes into skewer jj at the same time.

Chito realized after some thought that the robot might not be able to make the strawberry and grape counts equal on every skewer.

Check whether the robot can make the number of strawberries and Shine Muscat grapes equal on every skewer.

Input

The first line contains the number of skewers NN, the number of strawberries PP and the number of Shine Muscat grapes QQ that the robot inserts every minute, separated by spaces. (1≤N,P,Q≤106)(1 \leq N, P, Q \leq 10^{6})

The second line contains the number of strawberries on each skewer A1,A2,…,ANA_{1}, A_{2}, \ldots, A_{N}, separated by spaces. (1≤Ai≤106)(1 \leq A_{i} \leq 10^{6})

The third line contains the number of Shine Muscat grapes on each skewer B1,B2,…,BNB_{1}, B_{2}, \ldots, B_{N}, separated by spaces. (1≤Bi≤106)(1 \leq B_{i} \leq 10^{6})

Output

On the first line, print YES if the robot can make the strawberry and grape counts equal on every skewer, and NO otherwise.

If the robot can make the counts equal on every skewer, print on the second line the number of times the robot inserted strawberries into each skewer, separated by spaces. On the third line, print the number of times the robot inserted Shine Muscat grapes into each skewer, separated by spaces. If several answers are possible, print any one of them.

The strawberries and grapes are not unlimited, so the number of times the robot inserts PP strawberries and QQ grapes into each skewer must each be within 2×10122 \times 10^{12}.

Examples3

  1. Example 1

    Input
    3 2 1
    3 5 7
    5 6 7
    
    Expected output
    YES
    2 1 0
    2 1 0
    
  2. Example 2

    Input
    3 2 1
    3 5 7
    6 5 4
    
    Expected output
    NO
    
  3. Example 3

    Input
    3 4 8
    1 8 32
    9 4 8
    
    Expected output
    YES
    4 1 0
    1 1 3