Problem:


Mysterious Gems

宇宙暦 1603〜1867 年，人々はその時代のことを EDO 時代と呼ぶ．EDO とは当時最先端の宇宙航行技術，Enhanced Driving Operation のことであり、1603 年に Dr.Izy によって開発された．

あなたは宇宙冒険家であり，宇宙を飛び回って様々な惑星を冒険していた．その冒険の途中で，あなたはとても不思議な惑星を発見した．その惑星には，至るところに七色に輝く不思議な宝石が落ちていた．あなたはその惑星への降下を試みようと考えたが，重大な問題のためにそれは不可能であることがわかった．その惑星の空気には，人間が触れただけで即死してしまうような猛毒の成分が含まれていたのだ．

そこで，あなたはロボットを使って宝石を回収することを考えついた．あなたはその惑星の周回軌道にて待機する．そして，降下させたロボットを遠隔操作することによって宝石を回収するのだ．あなたは，ロボットに「移動する方向」と「移動する距離」の組からなる命令の列によってロボットを遠隔操作する．ロボットは移動経路上（到達点を含む）に宝石を見つけると，それらを全て回収する．

あなたの仕事は，ロボットが与えられた全ての命令の実行を終えたときに，全ての宝石を回収することができたかどうかを判定するプログラムを書くことである．

なお，ロボットが不思議な宝石を回収する範囲はそれほど広くない．そのため，ロボットが移動する範囲は全て 2 次元の平面で表すことができる．そして，ロボットが移動する範囲は (0,0) および (20,20) をそれぞれ左下隅および右上隅とする正方形の内部（境界線を含む）である．ロボットは常に範囲の中央，すなわち (10,10) の座標に降下する．また，全ての宝石は中央以外の格子点上にあることが保証されている．

Input

入力は複数のデータセットにより構成される．

それぞれのデータセットの先頭行には，単一の正の整数 N (1 <= N <= 20) が含まれる。これはロボットが移動可能な範囲内にある不思議な宝石の個数を表す．次の N 行には，それぞれ xi および yi (0 <= xi , yi <= 20) が含まれ，これは i 番目の不思議な宝石の落ちている座標を表す．なお，1 つの場所に複数の宝石が落ちていることはない．

次の行には単一の整数 M (1 <= M <= 30) が含まれ，これはロボットに与えた命令の個数を表す．この後の M 行にはそれぞれ dj とひとつの正の整数 lj が含まれる．これは j 番目の命令における方向および移動量を表す．ただし，方向は N，E，S，W のいずれかの文字であり，順に北，東，南，西を表す（北は y 軸の正方向，東は x 軸の正方向）．なお，ロボットが移動可能な範囲を超えるような命令は与えられないことが保証されている．

入力は N = 0 のときに終了し，これはデータセットに含まれない．

Output

それぞれのデータセットについて，ロボットが全ての宝石を収集できるときは「Yes」と，そうでないときは「No」と 1 行に出力しなさい．

Sample Input

2
10 11
11 12
2
N 2
E 1
2
10 11
11 12
2
N 2
W 1
3
0 15
5 10
5 15
5
W 10
S 10
N 20
E 10
S 10
0

Output for the Sample Input

Yes
No
No



Sample input:
2
10 11
11 12
2
N 2
E 1
2
10 11
11 12
2
N 2
W 1
3
0 15
5 10
5 15
5
W 10
S 10
N 20
E 10
S 10
0


Sample output:
Yes
No
No

Submission status: Wrong Answer

Solution code:
import sys

def move(cmd, gems):
    n = 0
    x = y = 10
    for c in cmd:
        d = c[0]
        l = c[1]
        for s in range(0, l):
            if d == "N":
                y += 1
            elif d == "E":
                x += 1
            elif d == "S":
                y -= 1
            elif d == "W":
                x -= 1
            if gems[y][x] == 1:
                n += 1
                gems[y][x] = 0
    return n

gems = []
cmd = []
att = "gemsN"
for line in sys.stdin:
    if att =="gemsN":
        n = w_n = int(line)
        if n == 0:
            break
        att = "gemsXY"
        gems = [ [0]*21 ]*21
    elif att == "gemsXY" and w_n > 0:
        xy = list(map(int, line.strip().split(" ")))
        gems[xy[1]][xy[0]] = 1
        w_n -= 1
    elif att == "gemsXY" and w_n == 0:
        att = "cmd"
        cmd = []
        m = int(line)
    elif att == "cmd" and m > 0:
        dl = line.strip().split(" ")
        cmd.append([dl[0], int(dl[1])])
        m -= 1
        if m == 0:
            a = move(cmd, gems)
            ans = "Yes" if a == n else "No"
            print(ans)
            att = "gemsN"

Submission status: Wrong Answer

Solution code:
def move(hougaku, zahyo):
    if hougaku == "N":
        zahyo[1] += 1
    elif hougaku == "E":
        zahyo[0] += 1
    elif hougaku == "S":
        zahyo[1] -= 1
    elif hougaku == "W":
        zahyo[0] -= 1


while True:
    N = int(input())
    if N == 0:
        break
    jewelry = [list(map(int, input().split())) for _ in range(N)]
    M = int(input())
    default = [10, 10]
    get_jewelry = 0
    for _ in range(M):
        d, l = input().split()
        for i in range(int(l)):
            move(d, default)
            if default in jewelry:
                get_jewelry += 1
    if len(jewelry) == get_jewelry:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
while True:
    num_hoseki=input()
    if num_hoseki==0:
        break
    
    hoseki_list=[]
    for i in range(num_hoseki):
        hoseki_list.append(map(int,raw_input().split()))
        
    num_meirei=input()
    
    keiro=[]
    x,y=[10,10]
    for i in range(num_meirei):
        meirei=raw_input()
        
        d, l=meirei.split()
        l=int(l)
        if d=='N':
            dx,dy=0,1
        elif d=='S':
            dx,dy=0,-1
        elif d=='W':
            dx,dy=-1,0
        elif d=='E':
            dx,dy=1,0

        for j in range(l):
            keiro.append([x+(j+1)*dx,y+(j+1)*dy])
        x,y=keiro[-1]
    flag=True
    for hoseki in hoseki_list:
        if not hoseki in keiro:
            flag=False
            break

Submission status: Wrong Answer

Solution code:
# coding: utf-8

class Mission:
  def __init__(self):
    self.field = [[0]*21 for i in range(21)]
    self.x = 10
    self.y = 10

  def get_gem(self, x, y):
    self.field[x][y] = 0

  def put_gem(self, x, y):
    self.field[x][y] = 1

  def move_x(self, step):
    for i in range(1,step+1): self.get_gem(self.x+i, self.y)
    self.x += step

  def move_y(self, step):
    for j in range(1,step+1): self.get_gem(self.x, self.y+j)
    self.y += step

def main():
  while True:
    n_gems = input()
    if n_gems == 0: break

    m = Mission()
    for i in range(n_gems):
      x, y = map(int, raw_input().split(' '))
      if (x, y) != (m.x, m.y): m.put_gem(x, y)

    n_commands = input()
    for i in range(n_commands):
      direction, step = raw_input().split(' ')
      step = int(step)

      if direction == 'N': m.move_y(step)
      elif direction == 'E': m.move_x(step)
      elif direction == 'S': m.move_y(-step)
      elif direction == 'W': m.move_x(-step)

    if m.field == [[0]*21 for i in range(21)]: print 'Yes'
    else: print 'No'

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
while 1:	
	n = int(raw_input())
	if n == 0:
		break
	search_map = [[0 for i in range(20)] for i in range(20)]

	for i in range(n):
		x, y = map(int,raw_input().split(" "))
		search_map[y-1][x-1] = 1

	here = [9,9]
	m = int(raw_input())
	for i in range(m):
		d, l = raw_input().split(" ")
		if d == "N" or d == "S":
			l = int(l) if d == "N" else int(l) * (-1)
			next = [here[0], here[1]+l]
			for j in range(min(here[1],next[1]), max(here[1],next[1]) + 1):
				search_map[j][here[0]] = 0
		else :
			l = int(l) if d == "E" else int(l) * (-1)
			next = [here[0]+l, here[1]]
			for j in range(min(here[0],next[0]), max(here[0],next[0]) + 1):
				search_map[here[1]][j] = 0
		here = next

	rest_gem = sum([sum(line) for line in search_map])
	print "Yes" if rest_gem == 0 else "No"

Submission status: Wrong Answer

Solution code:
while 1:	
	n = int(raw_input())
	if n == 0:
		break
	search_map = [[0 for i in range(20)] for i in range(20)]

	for i in range(n):
		x, y = map(int,raw_input().split(" "))
		search_map[y-1][x-1] = 1

	here = [9,9]
	m = int(raw_input())
	for i in range(m):
		d, l = raw_input().split(" ")
		l = int(l)
		l_sign = 1 if d == "N" or d == "E" else -1 
		if d == "N" or d == "S":
			next = [here[0], here[1]+l_sign*l]
			for j in range(1,l+1):
				search_map[here[1] + l_sign*j][here[0]] = 0
		else :
			next = [here[0]+l_sign*l, here[1]]
			for j in range(1,l+1):
				search_map[here[1]][here[0] + l_sign * j] = 0
		here = next
	rest_gem = sum([sum(line) for line in search_map])
	print "Yes" if rest_gem == 0 else "No"

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

while True:
    n = int(input())
    if n == 0 : break

    gems = []
    for i in range(n):
        gem = tuple(map(int, input().split()))
        gems.append(gem)
    
    m = int(input())
    bot = [10, 10]
    history = [(10, 10)]
    for j in range(m):
        move = list(input().split())
        move[1] = int(move[1])
        if move[0] == 'N':
            index = 1 #y
            direc = 1 # pos
        elif move[0] == 'S':
            index = 1
            derec = -1 # neg
        elif move[0] == 'E':
            index = 0 #x
            direc = 1
        else: #W
            index = 0
            direc = -1
        for j in range(abs(move[1])):
            bot[index] += direc
            history.append(tuple(bot))
    for g in gems:
        if g not in history:
            print("No")
            break
    print("Yes")

Submission status: Wrong Answer

Solution code:
while True:
    n = input()
    if n==0:
        break
    gem = [[0 for i in range(21)] for j in range(21)]
    dx = [-1,0,1,0]
    dy = [0,1,0,-1]
    for i in range(n):
        x,y = raw_input().split()
        x = int(x)
        y = int(y)
        gem[x][y] = 1
    m = input()
    ans = 0
    x = 10
    y = 10
    for i in range(m):
        di,var = raw_input().split()
        var = int(var)
        if di=="W":
            di = int(0)
        elif di=="N":
            di = int(1)
        elif di=="E":
            di = int(2)
        else: #if di=="S":
            di = int(3)
        for j in range(var):
            x += dx[di]
            y += dy[di]
            if gem[x][y]==1:
                ans += 1
    if n==ans:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1

        if cnt == gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1

        if cnt == gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    if y > 20:
                        y = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    if y < 0:
                        y = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    if x > 20:
                        x = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    if x < 0:
                        x = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        cnt += 1

        if cnt == gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]

Submission status: Wrong Answer

Solution code:
x = 10
y = 10
i = 0
j = 0
roboPos = []
gemPos = 0
orderPos = 0
gemNum = 0
orderNum = 0
cnt = 0
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        for i in range(orderPos,orderPos+orderNum):
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    if y > 20:
                        y = 20
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    if y < 0:
                        y = 0
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    if x > 20:
                        x = 20
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    if x < 0:
                        x = 0
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        cnt += 1

        if cnt == gemNum:
            print("Yes")
        else:
            print("No")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    if y > 20:
                        y = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        print("????????????????????°??????")
                        print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    if y < 0:
                        y = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        print("????????????????????°??????")
                        print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    if x > 20:
                        x = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        print("????????????????????°??????")
                        print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    if x < 0:
                        x = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        print("????????????????????°??????")
                        print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1

        if cnt >= gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    if y > 20:
                        y = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    if y < 0:
                        y = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    if x > 20:
                        x = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    if x < 0:
                        x = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        cnt += 1

        if cnt >= gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]

Submission status: Wrong Answer

Solution code:
#?????????????????§?¨?x,y
x = 10
y = 10
i = 0
j = 0
roboPos = []
#?????????????????????????????°
gemPos = 0
#??§?¨????????????????????????°
orderPos = 0
#??????????????°
gemNum = 0
#??????????????°
orderNum = 0
#??????????????????
cnt = 0
#???????????§?¨?
gemXY = []
#???????????????????????§?¨?
gemCollectedXY = []

def get_input():
    while True:
        try:
            a = input()
            if a == "0":
                break
            yield ''.join(a)
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())

    while orderPos + orderNum < len(array):

        gemNum = int(array[orderPos + orderNum])
        gemPos = orderPos + orderNum + 1
        #print("??????????????°???{0}".format(gemNum))
        for i in range(gemPos,gemPos+gemNum):
            gem_x,gem_y = array[i].split()
            gem_x,gem_y = int(gem_x),int(gem_y)
            gemXY.append([gem_x,gem_y])
            #print("??????????????????{0},{1}".format(gem_x,gem_y))

        orderNum = int(array[gemPos+gemNum])
        orderPos = gemPos+gemNum+1
        #print("??????????????°???{0}".format(orderNum))
        for i in range(orderPos,orderPos+orderNum):
            #print("?????????{0}".format(array[i]))
            direction,length = array[i].split()
            length = int(length)
            if  direction == "N":
                for j in range(length):
                    y += 1
                    if y > 20:
                        y = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY and roboPos not in gemCollectedXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        gemCollectedXY.append([x,y])
                        cnt += 1
            elif direction == "S":
                for j in range(length):
                    y -= 1
                    if y < 0:
                        y = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY and roboPos not in gemCollectedXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        gemCollectedXY.append([x,y])
                        cnt += 1
            elif direction == "E":
                for j in range(length):
                    x += 1
                    if x > 20:
                        x = 20
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY and roboPos not in gemCollectedXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        gemCollectedXY.append([x,y])
                        cnt += 1
            else:
                for j in range(length):
                    x -= 1
                    if x < 0:
                        x = 0
                    #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                    roboPos = [x,y]
                    if roboPos in gemXY and roboPos not in gemCollectedXY:
                        #print("????????????????????°??????")
                        #print("?????¨???????????§?¨????{0},{1}".format(x,y))
                        gemCollectedXY.append([x,y])
                        cnt += 1

        if cnt >= gemNum:
            print("Yes")
        else:
            print("No")
        #print("+++++++++++1???????????????+++++++++++++")
        del gemXY[:]
        x,y = 10,10
        cnt = 0
        del roboPos[:]