QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#7823. Two Throws

Statistiques

Six distinct numbers are placed on the faces of a die in an arbitrary manner. The die is rolled twice, and after each roll, the sum of the values on the four side faces is calculated. Given these two sums and the set of numbers on the die, determine which numbers could be on the face opposite to the one with the first given number.

Input

The first line contains six distinct positive integers $A_1, \dots, A_6$ separated by spaces, which are the numbers on the faces of the die, each not exceeding $10\,000$.

The second line contains two positive integers separated by a space — the sums of the values on the four side faces of the die resulting from its two rolls. Each sum does not exceed $40\,000$.

Output

In the first and only line, output the values that could be on the face of the die opposite to the face with the value $A_1$, in ascending order. If no such values exist, output $-1$.

Examples

Input 1

2 3 4 5 6 1
13 15

Output 1

4 6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.