Lonely Gomgomi Has Friends
InterviewTime limit1sMemory limit1024 MB
Given each friend's start point and allowed step lengths, decide whether the friend can reach the origin by moving axis-aligned by those lengths.
- Level
Medium4 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem

Today is Gomgomi's birthday.
For several days, Gomgomi has sent party invitations to friends and has looked forward to a fun birthday party.
Then why is Gomgomi alone right now...?
Are the friends unable to find the way...?
Surely they can't come to the party either...?
Gomgomi is at the origin of an infinite two-dimensional coordinate plane.
Each time a friend moves, the friend can pick one of the given distances and move that distance in one of the four directions: up, down, left, or right.
Given each friend's starting position and the distances that friend can move, check whether that friend can come to Gomgomi's birthday party.
Input
The first line contains the number of friends ().
Each friend's information is given on two lines.
The first line of the -th friend's information contains the starting position , (), separated by a space.
The second line of the -th friend's information contains the number of distances (), followed by distances (, ), separated by spaces.
All input values are integers.
Output
Print lines.

If the -th friend cannot come to the party, print Gave up on the -th line. If the friend can come, print Ta-da.