In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers.

Limak, a polar bear, lives on the North Pole. Close to the New Year, he helps somebody with delivering packages all around the world. Instead of coordinates of places to visit, Limak got a description how he should move, assuming that he starts from the North Pole. The description consists of n parts. In the i-th part of his journey, Limak should move t_{i} kilometers in the direction represented by a string dir_{i} that is one of: "North", "South", "West", "East".

Limak isn’t sure whether the description is valid. You must help him to check the following conditions:  If at any moment of time (before any of the instructions or while performing one of them) Limak is on the North Pole, he can move only to the South.  If at any moment of time (before any of the instructions or while performing one of them) Limak is on the South Pole, he can move only to the North.  The journey must end on the North Pole. 

Check if the above conditions are satisfied and print "YES" or "NO" on a single line.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 50).

The i-th of next n lines contains an integer t_{i} and a string dir_{i} (1 ≤ t_{i} ≤ 10^6, $\operatorname{dir}_{i} \in \{\text{North, South, West, East} \}$) — the length and the direction of the i-th part of the journey, according to the description Limak got.


-----Output-----

Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.


-----Examples-----
Input
5
7500 South
10000 East
3500 North
4444 West
4000 North

Output
YES

Input
2
15000 South
4000 East

Output
NO

Input
5
20000 South
1000 North
1000000 West
9000 North
10000 North

Output
YES

Input
3
20000 South
10 East
20000 North

Output
NO

Input
2
1000 North
1000 South

Output
NO

Input
4
50 South
50 North
15000 South
15000 North

Output
YES



-----Note-----

Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole. [Image]

Difficulty: EASY
Tags: Geometry

Implementation

Starter code:

Solutions:
n = int(input())
d = 40000
y = 0
cor = True
for i in range(n):
	(t, s) = input().split()
	t = int(t)
	if y == 0 and s[0] != 'S':
		cor = False
		break
	if y == 20000 and s[0] != 'N':
		cor = False
		break
	if s[0] == 'N':
		y -= t
		if y < 0:
			cor = False
			break
	elif s[0] == 'S':
		y += t
		if y > 20000:
			cor = False
			break
if y != 0:
	cor = False
if cor:
	print('YES')
else:
	print('NO')


n = int(input())
A = []
for i in range(n):
	B = list(input().split())
	if B[1] == 'North':
		A.append(-1 * int(B[0]))
	elif B[1] == 'South':
		A.append(int(B[0]))
	else:
		A.append('r')
del B
(flag, cord) = ('YES', 0)
for i in A:
	if i == 'r':
		if cord <= 0 or cord >= 20000:
			flag = 'NO'
			break
		else:
			continue
	if cord < 0:
		flag = 'NO'
		break
	elif cord > 20000:
		flag = 'NO'
		break
	cord += i
if cord == 0:
	print(flag)
else:
	print('NO')


def main():
	latitude = 0
	(n,) = read()
	for i in range(n):
		(l, d) = read(str)
		l = int(l)
		if latitude == 0:
			if d != 'South':
				return 'NO'
		if latitude == 20000:
			if d != 'North':
				return 'NO'
		if d == 'South':
			latitude += l
		elif d == 'North':
			latitude -= l
		if not 0 <= latitude <= 20000:
			return 'NO'
	if latitude != 0:
		return 'NO'
	return 'YES'

def read(callback=int):
	return list(map(callback, input().strip().split()))

def write(value, end='\n'):
	if value is None:
		return
	try:
		if not isinstance(value, str):
			value = ' '.join(map(str, value))
	except:
		pass
	print(value, end=end)
write(main())


def okay(jl):
	x = 0
	for (l, d) in jl:
		if x == 0 and d != 'S' or (x == 20000 and d != 'N'):
			return False
		if d == 'S':
			x += l
		if d == 'N':
			x -= l
		if x < 0 or x > 20000:
			return False
	return x == 0
n = int(input())
jl = []
for i in range(n):
	(l, d) = input().split()
	jl.append((int(l), d[0]))
print('YES' if okay(jl) else 'NO')


n = int(input())
dirs = []
strdir = {'West': 0, 'North': 1, 'East': 2, 'South': 3}
for x in range(0, n):
	line = input().split()
	dirs.append([strdir[line[1]], int(line[0])])
flag = True
cy = 0
for dir in dirs:
	if (cy == 0 or cy == 20000) and (dir[0] == 0 or dir[0] == 2):
		flag = False
		break
	if dir[0] == 1:
		cy = cy - dir[1]
	elif dir[0] == 3:
		cy = cy + dir[1]
	if cy < 0 or cy > 20000:
		flag = False
		break
if flag == True and cy != 0:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
p = 0
for _ in range(n):
	i = input().split()
	if i[1][0] not in set(['W', 'E']):
		if i[1][0] == 'N':
			if p != 0 and p >= int(i[0]):
				p -= int(i[0])
			else:
				print('NO')
				quit()
		elif p != 20000 and 20000 >= p + int(i[0]):
			p += int(i[0])
		else:
			print('NO')
			quit()
	elif p == 0 or p == 20000:
		print('NO')
		quit()
if p == 0:
	print('YES')
else:
	print('NO')


def Print(condition):
	if condition == 1:
		print('YES')
	else:
		print('NO')
	exit()
n = int(input())
location = 0
for i in range(n):
	list = [i for i in input().split()]
	t = int(list[0])
	d = list[1]
	if location == 0 and d != 'South' or (location == 20000 and d != 'North'):
		Print(0)
	if d == 'South':
		location = location + t
		if location > 20000:
			Print(0)
	elif d == 'North':
		location = location - t
		if location < 0:
			Print(0)
if location == 0:
	Print(1)
else:
	Print(0)


from typing import List
INF = float('inf')
NINF = float('-inf')

def read_string():
	return input()

def read_string_line():
	return [x for x in input().split(' ')]

def read_int_line():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

def get_int_arr(s):
	return [int(x) for x in s.split()]

def get_sum(acc, l, r):
	return acc[r] - acc[l]
P = int(1000000000.0 + 7)

def exgcd(x, y):
	if y == 0:
		return (x, 1, 0)
	(g, a, b) = exgcd(y, x % y)
	t = x // y
	return (g, b, a - t * b)

def inv(x):
	(g, a, b) = exgcd(x, P)
	return a

def calc_acc(arr):
	ans = [0]
	for a in arr:
		ans.append(a + ans[-1])
	return ans
lines: List[str] = [*open(0)]
y = 0
NP = 0
SP = 20000
for line in lines[1:]:
	(x, d) = line.split()
	x = int(x)
	if d in ('West', 'East'):
		if y in [NP, SP]:
			print('NO')
			break
		continue
	if y == NP and d == 'North' or (y == SP and d == 'South'):
		print('NO')
		break
	if d == 'North':
		x = -x
	y += x
	if y > SP or y < NP:
		print('NO')
		break
else:
	print('YES' if y == 0 else 'NO')


n = int(input())
x = 0
k = True
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	if b == 'South':
		if x == 20000:
			k = False
		x += a
		if x > 20000:
			k = False
	elif b == 'North':
		if x == 0:
			k = False
		x -= a
		if x < 0:
			k = False
	elif b == 'West':
		if x == 0 or x == 20000:
			k = False
	elif b == 'East':
		if x == 0 or x == 20000:
			k = False
if x != 0:
	k = False
if k:
	print('YES')
else:
	print('NO')


n = int(input())
a = []
y = 0
rez = 1
for i in range(n):
	b = list(input().split())
	b[0] = int(b[0])
	a.append(b)
for i in a:
	if y == 0:
		if i[1] == 'South':
			y += i[0]
			continue
		else:
			rez = 0
			break
	elif y == 20000:
		if i[1] == 'North':
			y -= i[0]
			continue
		else:
			rez = 0
			break
	else:
		if y > 20000:
			rez = 0
			break
		if y < 0:
			rez = 0
			break
		if i[1] == 'North':
			y -= i[0]
		if i[1] == 'South':
			y += i[0]
if rez != 0 and y == 0:
	print('YES')
else:
	print('NO')


from math import sin

def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
n = it()
s = 10000
r = 0
deg = 0
bl = True
for _ in range(n):
	(a, b) = input().split()
	c = int(a)
	if s == 10000 and b != 'South':
		bl = False
	elif s == -10000 and b != 'North':
		bl = False
	else:
		if b == 'North':
			if s + c > 10000:
				bl = False
			else:
				s += c
		if b == 'South':
			if s - c < -10000:
				bl = False
			else:
				s -= c
if bl:
	if s == 10000:
		pt('YES')
	else:
		pt('NO')
else:
	pt('NO')


dir = 0
ok = 0
for i in ' ' * int(input()):
	(a, b) = input().split()
	if b[0] == 'N':
		dir += -int(a)
	elif b[0] == 'S':
		dir += int(a)
	elif dir == 0 or dir == 20000:
		ok = 1
	if dir < 0 or dir > 20000:
		ok = 1
if dir or ok:
	print('NO')
else:
	print('YES')


n = int(input())
pole = 0
flag = True
for i in range(n):
	(mile, dire) = input().split()
	if pole == 0 and dire != 'South':
		print('NO')
		flag = False
		break
	elif pole == 20000 and dire != 'North':
		print('NO')
		flag = False
		break
	if dire == 'South':
		pole += int(mile)
		if pole > 20000:
			print('NO')
			flag = False
			break
	elif dire == 'North':
		pole -= int(mile)
		if pole < 0:
			print('NO')
			flag = False
			break
if flag and pole == 0:
	print('YES')
elif flag and pole != 0:
	print('NO')


n = int(input())
point = 0
for _ in range(n):
	(value, key) = input().split()
	if point == 0 and key != 'South':
		print('NO')
		break
	elif point == 20000 and key != 'North':
		print('NO')
		break
	if key == 'South':
		point += int(value)
	elif key == 'North':
		point -= int(value)
	if point > 20000 or point < 0:
		print('NO')
		break
else:
	print('YES' if point == 0 else 'NO')


n = int(input())
s = 0
for i in range(n):
	(t, dirt) = input().split()
	if dirt != 'South' and i == 0:
		print('NO')
		exit()
	if (dirt == 'East' or dirt == 'West') and (s == 0 or s == 20000):
		print('NO')
		exit()
	t = int(t)
	if dirt == 'South':
		s += t
	elif dirt == 'North':
		s -= t
	if s > 20000 or s < 0:
		print('NO')
		exit()
if s == 0:
	print('YES')
else:
	print('NO')


from sys import *
n = int(stdin.readline())
H = 0
ans = 'YES'
for _ in range(n):
	(x, d) = stdin.readline().rstrip().split(' ')
	x = int(x)
	if d == 'North':
		if x > H:
			ans = 'NO'
			continue
		H -= x
		continue
	if d == 'South':
		if H + x > 20000:
			ans = 'NO'
			continue
		H += x
		continue
	if H == 0 or H == 20000:
		ans = 'NO'
		continue
if H:
	ans = 'NO'
print(ans)


n = int(input())
p = 20000
ns = 0
res = 'YES'
for i in range(n):
	a = list(input().split())
	x = int(a[0])
	direct = str(a[1])
	if ns == 0 and (not direct == 'South'):
		res = 'NO'
		break
	if ns == p and (not direct == 'North'):
		res = 'NO'
		break
	if x > p and (direct == 'North' or direct == 'South'):
		res = 'NO'
		break
	if ns > p or ns < 0:
		res = 'NO'
		break
	if direct == 'South':
		ns += x
	if direct == 'North':
		ns -= x
if not ns == 0:
	res = 'NO'
print(res)


n = int(input())
ans = True
p = 0
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if p == 0 and d != 'South':
		ans = False
	if p == 20000 and d != 'North':
		ans = False
	if d == 'South':
		p += t
	if d == 'North':
		p -= t
	if p < 0 or p > 20000:
		ans = False
if p != 0:
	ans = False
print('YES' if ans else 'NO')


n = int(input())
(c, r) = (0, 1)
for i in range(n):
	(x, y) = map(str, input().split())
	if c == 0 and y != 'South' or (c == 20000 and y != 'North'):
		r = 0
	if y == 'South':
		c += int(x)
	if y == 'North':
		c -= int(x)
	if c < 0 or c > 20000:
		r = 0
if c == 0 and r == 1:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def bsearch(nums, target):
	N = len(nums or [])
	l = 0
	r = N - 1
	while l <= r:
		mid = (l + r) // 2
		if nums[mid] < target:
			l = mid + 1
		elif nums[mid] > target:
			r = mid - 1
		else:
			return (None, mid, None)
	return (r if r >= 0 else None, None, l if l <= N - 1 else None)

def yesOrNo(val):
	print('YES' if val else 'NO')

def printSpacedArray(nums):
	print(*nums)
n = inInt()
vert = -10000
for i in range(n):
	(amount, direction) = inSList()
	amount = int(amount)
	if vert == -10000:
		if direction != 'South':
			print('NO')
			quit()
	elif vert == 10000:
		if direction != 'North':
			print('NO')
			quit()
	if direction == 'South':
		vert += amount
	elif direction == 'North':
		vert -= amount
	if abs(vert) > 10000:
		print('NO')
		quit()
if vert == -10000:
	print('YES')
else:
	print('NO')


n = int(input())
h = 0
south = 20000
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d[0] in 'WE':
		if h == 0 or h == south:
			h = 228
			break
		else:
			continue
	if d[0] == 'N':
		if h == 0:
			h = 228
			break
		else:
			h -= t
	if d[0] == 'S':
		if h == south:
			h = 228
			break
		else:
			h += t
	if h < 0 or h > south:
		h = 228
		break
print(('YES', 'NO')[h != 0])


n = int(input())
x = 0
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	if (b == 'East' or b == 'West' or b == 'North') and x == 0:
		print('NO')
		exit()
	elif (b == 'East' or b == 'West' or b == 'South') and x == 20000:
		print('NO')
		exit()
	elif b == 'North' and x - a < 0 or (b == 'South' and x + a > 20000):
		print('NO')
		exit()
	elif b == 'North':
		x -= a
	elif b == 'South':
		x += a
print('NO' if x else 'YES')


n = int(input())
curr_direct = 'North'
curr_value = 0
for i in range(n):
	(value, direct) = input().split()
	if curr_direct == 'North' and direct != 'South' and (curr_value == 0):
		print('NO')
		break
	if curr_direct == 'South' and direct != 'North' and (curr_value == 20000):
		print('NO')
		break
	if direct == 'South':
		curr_value += int(value)
	if direct == 'North':
		curr_value -= int(value)
	curr_direct = direct
	if curr_value < 0 or curr_value > 20000:
		print('NO')
		break
else:
	if curr_value == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
coord = 0
for _ in range(n):
	inp = input().split()
	(km, dir) = (int(inp[0]), inp[1])
	if coord == 0 and dir != 'South':
		print('NO')
		exit(0)
	if coord == 20000 and dir != 'North':
		print('NO')
		exit(0)
	if dir == 'North':
		coord -= km
	if dir == 'South':
		coord += km
	if coord < 0 or coord > 20000:
		print('NO')
		exit(0)
print('YES' if coord == 0 else 'NO')


x = int(input())
ans = 'YES'
lst = []
cur = 0
s = {'West', 'East'}
for i in range(x):
	lst.append(input().split())
for i in range(len(lst)):
	if lst[i][1] == 'South':
		lst[i][0] = int(lst[i][0])
	elif lst[i][1] == 'North':
		lst[i][0] = int(lst[i][0])
for i in lst:
	if i[1] == 'North':
		cur -= int(i[0])
		if cur < 0:
			ans = 'NO'
			break
	elif i[1] == 'South':
		cur += int(i[0])
		if cur > 20000:
			ans = 'NO'
			break
	elif cur == 0 or cur == 20000:
		ans = 'NO'
		break
if cur == 0 and ans == 'YES':
	print('YES')
else:
	print('NO')


n = int(input())
a = []
pos = 0
flag = True
for i in range(0, n):
	temp = input().split()
	if temp[1] == 'North':
		pos -= int(temp[0])
		if pos < 0:
			flag = False
			break
		continue
	elif temp[1] == 'South':
		pos += int(temp[0])
		if pos > 20000:
			flag = False
			break
		continue
	if pos >= 20000 and temp[1] != 'North':
		flag = False
		break
	elif pos <= 0 and temp[1] != 'South':
		flag = False
		break
if flag and pos == 0:
	print('YES')
else:
	print('NO')


n = int(input())
p = 20000
r = 'YES'
for i in range(n):
	(tStr, d) = input().split()
	t = int(tStr)
	if p == 20000 and d != 'South':
		r = 'No'
	if p == 0 and d != 'North':
		r = 'No'
	if d == 'South':
		p -= t
		if p < 0:
			r = 'No'
	if d == 'North':
		p += t
		if p > 20000:
			r = 'No'
if p != 20000:
	r = 'NO'
print(r)


n = int(input())
y = 0
for i in range(n):
	(am, direction) = input().split()
	if y == -20000 and direction != 'North' or (y == 0 and direction != 'South'):
		y = 1
	if direction == 'South':
		y -= int(am)
	elif direction == 'North':
		y += int(am)
	if not 0 >= y >= -20000:
		break
if y == 0:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
n = int(stdin.readline())
length = 20000
(xs, ys) = (0, length)
(x, y) = (0, length)
label = 1
for i in range(n):
	(step, f) = stdin.readline().strip().split()
	step = int(step)
	if f == 'South':
		y -= step
		if y < 0:
			label = 0
	elif f == 'North':
		y += step
		if y > length:
			label = 0
	elif f == 'West':
		x -= step
		if y == length or not y:
			label = 0
	elif f == 'East':
		x += step
		if y == length or not y:
			label = 0
if label and y == ys:
	stdout.write('YES')
else:
	stdout.write('NO')


n = int(input())
a = []

def die():
	print('NO')
	exit()
for i in range(n):
	(c, d) = input().split()
	a.append((int(c), d))
x = 0
for i in range(len(a)):
	if a[i][1] == 'South':
		x += a[i][0]
	elif a[i][1] == 'North':
		x -= a[i][0]
	if (x == 0 or x == 20000) and (a[i][1] == 'East' or a[i][1] == 'West'):
		die()
	if x > 20000 or x < 0:
		die()
if x != 0:
	die()
print('YES')


(h, south, ok) = (0, 20000, True)
for i in range(int(input())):
	(t, d) = input().split()
	if d[0] in 'NS':
		h += (-int(t), int(t))[d[0] == 'S']
	if d[0] in 'WE' and h in (0, south) or not 0 <= h <= south:
		ok = False
print(('NO', 'YES')[ok and h == 0])


n = int(input())
now = 0
flag = False
for i in range(n):
	(a, b) = input().split()
	if now == 0:
		if b[0] != 'S':
			flag = True
		else:
			now += int(a)
	elif now < 0 or now > 20000:
		flag = True
	elif now == 20000:
		if b[0] != 'N':
			flag = True
		else:
			now -= int(a)
	elif b[0] == 'N':
		now -= int(a)
	elif b[0] == 'S':
		now += int(a)
if now == 0 and (not flag):
	print('YES')
else:
	print('NO')


def f():
	n = int(input())
	d = 0
	ok = True
	for i in range(n):
		(l, direction) = input().split()
		if direction == 'North':
			d -= int(l)
		elif direction == 'South':
			d += int(l)
		elif d % 20000 == 0 and l != 0:
			ok = False
			break
		if d < 0 or d > 20000:
			ok = False
			break
	if d != 0 or not ok:
		print('NO')
	else:
		print('YES')
f()


r = 0
a = ''
k = 0
for i in range(int(input())):
	(ti, diri) = [j for j in input().split()]
	ti = int(ti)
	if r == 0 and diri != 'South':
		a = 'NO'
		break
	if r == 20000 and diri != 'North':
		a = 'NO'
		break
	if diri == 'South':
		r += ti
	if diri == 'North':
		r -= ti
	if r > 20000:
		a = 'NO'
		break
	if r < 0:
		a = 'NO'
		break
if r == 0 and a != 'NO':
	print('YES')
else:
	print('NO')


x = int(input())
ns = 0
r = 0
resposta = ''
for i in range(x):
	(a, b) = input().split()
	a = int(a)
	if b == 'North':
		ns -= a
	elif b == 'South':
		ns += a
	elif (b == 'West' or b == 'East') and (ns == 0 or ns == 20000):
		r = -1
	if ns < 0 or ns > 20000:
		r = -1
if r == 0 and ns == 0:
	print('YES')
else:
	print('NO')


n = int(input().strip())
delta = 0
flag = 0
for i in range(n):
	(d, dir) = input().strip().split()
	d = int(d)
	if dir == 'North':
		delta -= d
	elif dir == 'South':
		delta += d
	elif delta == 0 or delta == 20000:
		flag = 1
	if delta < 0 or delta > 20000:
		flag = 1
if delta or flag:
	print('NO')
else:
	print('YES')


def main():
	n = int(input())
	cur = 0
	for i in range(n):
		(x, d) = input().split()
		if d == 'South':
			cur += int(x)
			if cur > 20000:
				print('NO')
				return
		elif d == 'North':
			cur -= int(x)
			if cur < 0:
				print('NO')
				return
		elif cur in (0, 20000):
			print('NO')
			return
	print('YES' if cur == 0 else 'NO')
main()


n = int(input())
path = 0
for i in range(n):
	(d, w) = input().split()
	if path == 0 and w != 'South':
		print('NO')
		exit()
	elif path == 20000 and w != 'North':
		print('NO')
		exit()
	else:
		dis = int(d)
		if w == 'South':
			path += dis
			if path > 20000:
				print('NO')
				exit()
		elif w == 'North':
			path -= dis
			if path < 0:
				print('NO')
				exit()
if path == 0:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
ns = 0
poss = True
for i in range(int(input())):
	(dist, direction) = input().split()
	if direction == 'North':
		ns -= int(dist)
		if ns < 0:
			poss = False
			break
	elif direction == 'South':
		ns += int(dist)
		if ns > 20000:
			poss = False
			break
	elif direction == 'East' or direction == 'West':
		if 20000 != ns != 0:
			pass
		else:
			poss = False
			break
if not poss or ns != 0:
	print('NO')
else:
	print('YES')


n = int(input())
num = 0
flag = True
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	if num == 0 and b != 'South':
		flag = False
	if num == 20000 and b != 'North':
		flag = False
	if b == 'North':
		num -= a
		if num < 0:
			flag = False
	elif b == 'South':
		num += a
		if num > 20000:
			flag = False
if num != 0:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


import re
n = int(input())
a = []
North = re.compile('(\\d+)\\sNorth')
South = re.compile('(\\d+)\\sSouth')
dist = 0
flag = 0
for i in range(n):
	a.append(input())
for i in range(n):
	match1 = North.search(a[i])
	match2 = South.search(a[i])
	if match1 != None:
		var = int(match1.group(1))
		dist = dist - var
		if dist < 0:
			flag = -1
		elif dist == 0:
			if i < n - 1:
				m1 = South.search(a[i + 1])
				if m1 == None:
					flag = -1
	elif match2 != None:
		var = int(match2.group(1))
		dist = dist + var
		if dist > 20000:
			flag = -1
			break
		elif dist == 20000:
			if i < n - 1:
				m1 = North.search(a[i + 1])
				if m1 == None:
					flag = -1
if South.search(a[0]) == None:
	flag = -1
if dist != 0:
	flag = -1
if flag == -1:
	print('No')
else:
	print('Yes')


import os
LOCAL_PC = 'n1amr' in os.path.expanduser('~')
R = 40000
R2 = R // 2
DIRECTIONS = {'North': -1, 'South': 1, 'East': 0, 'West': 0}

def solve(input, print):
	n = int(input())
	moves = []
	for i in range(n):
		(x, y) = input().split()
		moves.append(int(x) * DIRECTIONS[y])
	print('YES' if ans(moves) else 'NO')

def ans(moves):
	cur = 0
	for dist in moves:
		if cur == 0 and dist <= 0 or (cur == R2 and dist >= 0):
			return False
		cur = cur + dist
		if cur < 0 or cur > R2:
			return False
	return cur == 0

def process_file(in_name, out_name):
	with open(in_name, 'r') as fin:
		with open(out_name, 'w') as fout:

			def read():
				return fin.readline().rstrip('\n')

			def write(*args, end='\n'):
				text = ' '.join(map(str, args)) + end
				fout.write(text)
				print(text, end='')
			t = int(fin.readline())
			for i in range(t):
				read()
				write('Case #{T}:\n'.format(T=i + 1), end='')
				solve(read, write)
				write()

def process_stdio():

	def read():
		return input()

	def write(*args, end='\n'):
		print(*args, end=end)
	solve(read, write)
if LOCAL_PC:
	in_name = __file__[:-3] + '.in'
	out_name = __file__[:-3] + '.out'
	process_file(in_name, out_name)
else:
	process_stdio()


num = int(input())
flag = 0
KGMoves = 0
if num > 50 or num < 1:
	flag += 1
dirc = []
for z in range(0, num):
	q = input()
	zr = q.split(' ')
	zr[0] = int(zr[0])
	if (zr[0] < 1 or zr[0] > 10 ** 6) or (zr[1] != 'North' and zr[1] != 'South' and (zr[1] != 'East') and (zr[1] != 'West')):
		flag += 1
	dirc += zr
c = 0
if flag == 0:
	for i in dirc[1:len(dirc):2]:
		if i == 'North' and KGMoves != 0:
			KGMoves -= dirc[c]
			c += 2
			if KGMoves < 0:
				KGMoves = 0
				flag = 1
		elif i == 'South' and KGMoves != 20000:
			KGMoves += dirc[c]
			c += 2
			if KGMoves > 20000:
				KGMoves = 20000
				flag = 1
		elif i != 'South' and KGMoves == 0:
			flag = 1
		elif i != 'North' and KGMoves == 20000:
			flag = 1
		else:
			c += 2
	if KGMoves == 0 and flag == 0:
		print('YES')
	else:
		print('NO')


import math
import sys
n = int(input())
polar = 0
for _ in range(n):
	(r, dir) = map(str, input().split())
	r = int(r)
	if dir == 'South':
		polar += r
	elif dir == 'North':
		polar -= r
	elif polar == 20000 or polar == 0:
		print('NO')
		break
	if polar < 0 or polar > 20000:
		print('NO')
		break
else:
	if polar == 0:
		print('YES')
	else:
		print('NO')


x = 0
y = 0
req = int(input())
for i in range(req):
	(distance, direction) = map(str, input().split())
	distance = int(distance)
	if direction == 'North':
		if y == 0 or y - distance < 0:
			print('NO')
			exit(0)
		else:
			y -= distance
			if y < 0:
				y = abs(y)
	elif direction == 'South':
		if y == 20000 or y + distance > 20000:
			print('NO')
			exit(0)
		else:
			y += distance
			if y > 20000:
				y %= 20000
	elif direction == 'West':
		if y == 0 or y == 20000:
			print('NO')
			exit(0)
		x += distance
		x %= 40000
	else:
		if y == 0 or y == 20000:
			print('NO')
			exit(0)
		x -= distance
		x %= 40000
if y == 0:
	print('YES')
else:
	print('NO')


posy = 10000
flag = 0
n = int(input())
for i in range(n):
	(num, direction) = input().split()
	num = int(num)
	if posy > 10000 or posy < -10000:
		flag = 1
	if posy == 10000 and direction != 'South':
		flag = 1
	elif posy == -10000 and direction != 'North':
		flag = 1
	if direction == 'South':
		posy -= num
	elif direction == 'North':
		posy += num
if posy == 10000 and flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = 0
r = 'YES'
l = False
k = False
for i in range(n):
	(a, ch) = input().split()
	a = int(a)
	if i == 0 and ch != 'South':
		r = 'NO'
	elif l and ch != 'North':
		r = 'NO'
	elif k and ch != 'South':
		r = 'NO'
	else:
		l = False
		k = False
	if ch == 'South':
		s += a
	elif ch == 'North':
		s -= a
	if s == 20000:
		l = True
	elif s == 0:
		k = True
	if s > 20000 or 0 > s:
		r = 'NO'
if s != 0:
	r = 'NO'
print(r)


up = 0
down = 20000
pos = up
n = int(input())
for _ in range(n):
	(dist, dir) = input().split()
	dist = int(dist)
	if pos == up and dir != 'South':
		print('NO')
		break
	if pos == down and dir != 'North':
		print('NO')
		break
	if dir == 'North':
		pos -= dist
	elif dir == 'South':
		pos += dist
	if not up <= pos <= down:
		print('NO')
		break
else:
	print('YES' if pos == up else 'NO')


n = int(input())
var = 0
ans = 'YES'
for i in range(n):
	query = input().split()
	stat = 0
	if var == 0 and query[1] != 'South' or (var == 20000 and query[1] != 'North'):
		stat = 1
	if query[1] == 'South':
		var += int(query[0])
	elif query[1] == 'North':
		var -= int(query[0])
	if not 0 <= var <= 20000:
		stat = 1
	if stat:
		ans = 'NO'
		for x in range(n - i - 1):
			input()
		break
if var != 0:
	ans = 'NO'
print(ans)


(h, o) = (0, 1)
for i in range(int(input())):
	(t, d) = input().split()
	if d[0] in 'NS':
		h += int(t) * (2 * (d[0] == 'S') - 1)
	elif h % 20000 == 0:
		o = 0
	if not -1 < h < 20001:
		o = 0
print(('NO', 'YES')[o * (h == 0)])


n = int(input())
b = int(0)
c = int(0)
for i in range(n):
	x = input()
	ara = x.split()
	a = int(ara[0])
	s = ara[1]
	if b == 0 and s != 'South':
		c = 1
	if b == 20000 and s != 'North':
		c = 1
	if s == 'North':
		b -= a
	if s == 'South':
		b += a
	if b < 0 or b > 20000:
		c = 1
if b == 0 and c == 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = 0
flag = 0
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d == 'North':
		if x - t < 0:
			flag = 1
		x = max(0, x - t)
	if d == 'South':
		if x + t > 20000:
			flag = 1
		x = min(20000, x + t)
	if x == 0 and d != 'North':
		flag = 1
	if x == 20000 and d != 'South':
		flag = 1
print('YES' if x == 0 and flag == 0 else 'NO')


n = int(input())
tx = 0
ty = 20000
res = True
for i in range(n):
	(t, d) = map(str, input().split())
	if d == 'South':
		ty -= int(t)
		if ty < 0:
			res = False
	elif d == 'North':
		ty += int(t)
		if ty > 20000:
			res = False
	elif d == 'West':
		tx -= int(t)
		if ty == 0 or ty == 20000:
			res = False
	elif d == 'East':
		tx += int(t)
		if ty == 0 or ty == 20000:
			res = False
if res and ty == 20000:
	print('YES')
else:
	print('NO')


n = int(input())
now = 0
marker = True
for i in range(n):
	line = list(input().split())
	if line[1] == 'East' or line[1] == 'West':
		if now != 0 and now != 20000:
			continue
		else:
			marker = False
			break
	else:
		if line[1] == 'North':
			now -= int(line[0])
		else:
			now += int(line[0])
		if not (now >= 0 and now <= 20000):
			marker = False
			break
if marker and now == 0:
	print('YES')
else:
	print('NO')


n = int(input())
y = 0
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d == 'South':
		if y + t > 20000 or y == 20000:
			print('NO')
			raise SystemExit
		y += t
	if d == 'North':
		if y - t < 0 or y == 0:
			print('NO')
			raise SystemExit
		y -= t
	if d == 'West' or d == 'East':
		if y == 0 or y == 20000:
			print('NO')
			raise SystemExit
if y != 0:
	print('NO')
	raise SystemExit
print('YES')


import sys
n = int(input())
dist = 0
for i in range(n):
	(k, s) = input().split()
	k = int(k)
	if s[0] == 'N':
		dist = dist - k
	elif s[0] == 'S':
		dist = dist + k
	elif (dist == 0 or dist == 20000) and (s[0] == 'E' or s[0] == 'W'):
		print('NO')
		break
	if dist < 0 or dist > 20000:
		print('NO')
		break
	if i == n - 1 and dist != 0:
		print('NO')
	elif i == n - 1 and dist == 0:
		print('YES')


n = int(input())
pos = 0
flag = False
for _ in range(n):
	(d, di) = input().split()
	if pos == 0 and di != 'South' or (pos == 20000 and di != 'North'):
		flag = True
		break
	if di == 'South':
		pos += int(d)
		if pos > 20000:
			flag = True
			break
	if di == 'North':
		pos -= int(d)
		if pos < 0:
			flag = True
			break
if pos != 0 or flag:
	print('NO')
else:
	print('YES')


x = 0
for _ in range(int(input())):
	(t, dir) = input().split()
	if x == 0 and dir != 'South' or (x == 20000 and dir != 'North'):
		print('NO')
		break
	x += int(t) if dir == 'South' else -int(t) if dir == 'North' else 0
	if x < 0 or x > 20000:
		print('NO')
		break
else:
	print('NO' if x else 'YES')


n = int(input())
dist = 0
for _ in range(n):
	(t, di) = input().split()
	t = int(t)
	if di == 'North':
		if dist == 0 or dist < t:
			print('NO')
			break
		dist -= t
	elif di == 'South':
		if dist == 20000 or 20000 - dist < t:
			print('NO')
			break
		dist += t
	elif dist == 20000 or dist == 0:
		print('NO')
		break
else:
	if dist == 0:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	aa = [LS() for _ in range(n)]
	t = 0
	for (a, d) in aa:
		a = int(a)
		if t == 0 and d != 'South':
			return 'NO'
		if t == 20000 and d != 'North':
			return 'NO'
		if d == 'South':
			t += a
			if t > 20000:
				return 'NO'
		elif d == 'North':
			t -= a
			if t < 0:
				return 'NO'
	if t == 0:
		return 'YES'
	return 'NO'
print(main())


flag = False
count = 0
cord = 0
n = int(input())
for x in range(n):
	(a, di) = input().split()
	a = int(a)
	if cord == 0 and di != 'South':
		flag = True
	elif cord == 20000 and di != 'North':
		flag = True
	if di == 'South':
		cord += a
	elif di == 'North':
		cord -= a
	if cord < 0 or cord > 20000:
		flag = True
if cord == 0 and flag == False:
	print('YES')
else:
	print('NO')


n = int(input())
s = 0
for i in range(n):
	lst = input().split()
	lst[0] = int(lst[0])
	if lst[1] == 'South' and s + lst[0] <= 20000:
		s += lst[0]
	elif lst[1] == 'South' and s + lst[0] > 20000:
		print('No')
		exit()
	elif lst[1] == 'North' and s - lst[0] >= 0:
		s -= int(lst[0])
	elif lst[1] == 'North' and s - lst[0] < 0:
		print('No')
		exit()
	elif (lst[1] == 'East' or lst[1] == 'West') and (s == 0 or s == 20000):
		print('No')
		exit()
if s == 0:
	print('Yes')
else:
	print('No')


n = int(input())
up = 20000
ans = True
for i in range(n):
	(le, dr) = map(str, input().split())
	le = int(le)
	if up == 20000 and dr != 'South' or (up == 0 and dr != 'North'):
		ans = False
	elif dr == 'South':
		if le > up:
			ans = False
		else:
			up -= le
	elif dr == 'North':
		if le > 20000 - up:
			ans = False
		else:
			up += le
if up != 20000:
	ans = False
if ans:
	print('YES')
else:
	print('NO')


def main():
	(x, res) = (0, True)
	for _ in range(int(input())):
		(s, d) = input().split()
		t = int(s)
		if d == 'South':
			if x + t <= 20000:
				x += t
			else:
				res = False
				break
		elif d == 'North':
			if x - t >= 0:
				x -= t
			else:
				res = False
				break
		elif not 0 < x < 20000:
			res = False
			break
	print(('NO', 'YES')[res and (not x)])
main()


q = int(input())
k = 0
for i in range(q):
	w = input().split()
	if k == 0 and w[1] != 'South':
		k = 'a'
		print('NO')
		break
	if k == 20000 and w[1] != 'North':
		k = 'a'
		print('NO')
		break
	if w[1] == 'North':
		k -= int(w[0])
	if w[1] == 'South':
		k += int(w[0])
	if k < 0 or k > 20000:
		print('NO')
		k = 'a'
		break
if k == 0:
	print('YES')
elif k != 'a':
	print('NO')


n = int(input())
ns = 0
end = False
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	if end:
		pass
	if b == 'South':
		if a + ns > 20000:
			end = True
		ns += a
	elif b == 'North':
		if ns - a < 0:
			end = True
		ns -= a
	elif ns == 0 or ns == 20000:
		end = True
print('YES' if ns == 0 and (not end) else 'NO')


def f(n):
	x = 0
	for i in range(n):
		(c, d) = input().split()
		if x == 0 and d != 'South' or (x == 20000 and d != 'North'):
			return False
		if d in ('East', 'West'):
			continue
		x += (1 if d == 'South' else -1) * int(c)
		if x < 0 or x > 20000:
			return False
	return x == 0
print('YES' if f(int(input())) else 'NO')


n = int(input())
ans = chk = 0
for i in range(n):
	(t, d) = map(str, input().split())
	t = int(t)
	if chk == 0 and d == 'South' and (t <= 20000):
		chk += t
	elif chk == 0:
		ans = 1
	elif chk == 20000 and d == 'North' and (t <= 20000):
		chk -= t
	elif chk == 20000:
		ans = 1
	elif d == 'North' and chk - t >= 0:
		chk -= t
	elif d == 'North':
		ans = 1
	elif d == 'South' and chk + t <= 20000:
		chk += t
	elif d == 'South':
		ans = 1
if chk == 0 and ans == 0:
	print('YES')
else:
	print('NO')


x = 0
y = 0
N = int(input())
for _ in range(N):
	a = input().split()
	(dist, dire) = (int(a[0]), a[1])
	if x == 0 and dire != 'South' or (x == 20000 and dire != 'North'):
		print('NO')
		exit(0)
	if dire == 'South':
		if dist >= 40000 or x + dist > 20000:
			print('NO')
			exit(0)
		x += dist
	elif dire == 'North':
		if dist <= -40000 or x - dist < 0:
			print('NO')
			exit(0)
		x -= dist
	if x < 0:
		x %= -40000
		if x > -20000 and x < 0:
			x *= -1
		else:
			x += 40000
	elif x > 20000:
		x %= 40000
		if x > 20000:
			x = 40000 - x
if x == 0:
	print('YES')
else:
	print('NO')


n = int(input())
t = 0
for i in range(n):
	(l1, s) = input().split()
	l = int(l1)
	if t == 20000 and s != 'North':
		print('NO')
		quit()
	elif t == 0 and s != 'South':
		print('NO')
		quit()
	elif s == 'South':
		if 20000 - t >= l:
			t += l
		else:
			print('NO')
			quit()
	elif s == 'North':
		if l <= t:
			t -= l
		else:
			print('NO')
			quit()
print('YES' if t == 0 else 'NO')


n = int(input())
(pos, result) = (0, True)
for i in range(n):
	(t, dire) = input().split(' ')
	if pos == 0 and dire != 'South':
		result = False
	if pos == 20000 and dire != 'North':
		result = False
	if dire == 'East' or dire == 'West':
		continue
	t = int(t)
	if dire == 'South':
		pos = pos + t
	else:
		pos = pos - t
	if pos < 0 or pos > 20000:
		result = False
if pos == 0 and result:
	print('YES')
else:
	print('NO')


N = int(input())
nowy = 10000
nowx = 0
for i in range(N):
	(t, direction) = input().split()
	t = int(t)
	if direction == 'North':
		if nowy + t > 10000:
			print('NO')
			exit()
		nowy += t
	elif direction == 'South':
		if nowy - t < -10000:
			print('NO')
			exit()
		nowy -= t
	elif direction == 'East':
		if nowy == 10000 or nowy == -10000:
			print('NO')
			exit()
		nowx += t
		nowx %= 40000
	elif direction == 'West':
		if nowy == 10000 or nowy == -10000:
			print('NO')
			exit()
		nowx -= t
		nowx %= 40000
if nowy == 10000:
	print('YES')
else:
	print('NO')


n = int(input())
y = 0
for i in range(n):
	[a, b] = input().split()
	t = int(a)
	if y == 0 and b != 'South':
		print('NO')
		exit(0)
	if y == 20000 and b != 'North':
		print('NO')
		exit(0)
	if b == 'South':
		y += t
		if y > 20000:
			print('NO')
			exit(0)
	elif b == 'North':
		y -= t
		if y < 0:
			print('NO')
			exit(0)
if y != 0:
	print('NO')
else:
	print('YES')


n = int(input())
t = 20000
f = True
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	if b == 'South':
		t -= a
	elif b == 'North':
		t += a
	elif t == 0 or t == 20000:
		f = False
	if not 0 <= t <= 20000:
		f = False
if f and t == 20000:
	print('Yes')
else:
	print('No')


from sys import *
n = int(input())
hi = 20000
for i in range(n):
	s = input().split()
	if s[1][0] == 'S':
		hi -= int(s[0])
	elif s[1][0] == 'N':
		hi += int(s[0])
	elif hi in [0, 20000]:
		print('NO')
		return
	if not 0 <= hi <= 20000:
		print('NO')
		return
if hi == 20000:
	print('YES')
else:
	print('NO')


n = int(input())
t = 0
c = 'YES'
g = 0
for i in range(n):
	(a, b) = map(str, input().split())
	if b == 'South':
		t = t + int(a)
	if b == 'North':
		t = t - int(a)
	if t < 0 or t > 20000:
		c = 'NO'
	if t == 20000 and b != 'South':
		c = 'NO'
	if t == 0 and b != 'South' and (b != 'North'):
		c = 'NO'
if t != 0:
	c = 'NO'
print(c)


n = int(input())
k = 20000
for i in range(n):
	q = input()
	i = 0
	a = 0
	while q[i] != ' ':
		a = a * 10 + int(q[i])
		i += 1
	b = q[i + 1:]
	if b == 'North':
		k += a
		if k > 20000:
			print('NO')
			exit()
	elif b == 'South':
		k -= a
		if k < 0:
			print('NO')
			exit()
	elif b == 'West':
		if (k == 20000 or k == 0) and a != 0:
			print('NO')
			exit()
	elif b == 'East':
		if (k == 20000 or k == 0) and a != 0:
			print('NO')
			exit()
if k == 20000:
	print('YES')
else:
	print('NO')


def main():
	flag = 1
	cur = 0
	n = int(input())
	for i in range(n):
		str = input().split()
		m = int(str[0])
		str = str[1]
		if str == 'South':
			if cur + m > 20000:
				flag = 0
			else:
				cur += m
		elif str == 'North':
			if cur - m < 0:
				flag = 0
			else:
				cur -= m
		elif cur == 0 or cur == 20000:
			flag = 0
		else:
			pass
	if cur == 0 and flag:
		print('YES')
	else:
		print('NO')
main()


import sys

def main():
	n = int(sys.stdin.readline().strip())
	(dirs, dists) = ([], [])
	earth_circum = 40000
	lat = 0
	north = 'North'
	south = 'South'
	for i in range(n):
		(distance, direction) = [s for s in sys.stdin.readline().split()]
		distance = int(distance)
		if direction == north:
			distance *= -1
		dirs.append(direction)
		dists.append(distance)
	for (distance, direction) in zip(dists, dirs):
		if distance == 0:
			continue
		if lat == 0 and direction != south:
			print('NO')
			return
		if lat == earth_circum / 2 and direction != north:
			print('NO')
			return
		if direction in [south, north]:
			if abs(lat + distance) > earth_circum / 2:
				print('NO')
				return
			if lat + distance < 0:
				print('NO')
				return
			lat += distance
	print('YES' if lat == 0 else 'NO')
main()


n = int(input())
p = 0
for i in range(n):
	(t, d) = input().split(' ')
	if d == 'East' or d == 'West':
		if p == 0 or p == 20000:
			p = -1
			break
		continue
	t = int(t)
	if d == 'North':
		t = -t
	p += t
	if p < 0 or p > 20000:
		break
print('YES' if p == 0 else 'NO')


n = int(input())
l = 0
for i in range(n):
	(x, d) = input().split()
	x = int(x)
	if (d == 'East' or d == 'West') and (l != 0 and l != 20000):
		continue
	if (d == 'East' or d == 'West') and (l == 0 or l == 20000):
		print('NO')
		exit()
	if d == 'South':
		l += x
	if d == 'North':
		l -= x
	if l < 0 or l > 20000:
		print('NO')
		exit()
if l == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = 0
for i in range(n):
	(a, b) = input().split()
	if b[0] == 'E' or b[0] == 'W':
		if s == 0 or s == 20000:
			print('NO')
			exit(0)
	else:
		if b[0] == 'N':
			s -= int(a)
		else:
			s += int(a)
		if s < 0 or s > 20000:
			print('NO')
			exit(0)
if s == 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = 0
con3 = 'YES'
for i in range(0, n):
	s = input()
	s = s.split()
	s[0] = int(s[0])
	if (s[0] < 0 or s[0] > 20000) and (s[1] == 'North' or s[1] == 'South'):
		con3 = 'NO'
	if s[1] == 'North':
		x -= s[0]
	elif s[1] == 'South':
		x += s[0]
	if x < 0 or x > 20000:
		con3 = 'NO'
	if (x == 0 or x == 20000) and (s[1] == 'West' or s[1] == 'East'):
		con3 = 'NO'
if x != 0:
	con3 = 'NO'
print(con3)


MAXI = 20000
n = int(input())
y = 0
ok = True
for i in range(n):
	(s, d) = input().split()
	if y == 0 and d != 'South':
		ok = False
	elif y == MAXI and d != 'North':
		ok = False
	elif d in ['West', 'East']:
		continue
	s = int(s)
	if d == 'North':
		s *= -1
	y += s
	if not 0 <= y <= 20000:
		ok = False
if y != 0:
	ok = False
if ok:
	print('YES')
else:
	print('NO')


import sys
import math
sys.setrecursionlimit(5000000)

def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]

def abs(num):
	return num if num > 0 else -num
L = 20000
c = 0
error = False
n = read()
for i in range(n):
	(x, d) = read_arr(str)
	x = int(x)
	if c == 0 and d != 'South':
		error = True
		break
	if c == 0 and x > L:
		error = True
		break
	if c == L and d != 'North':
		error = True
		break
	if c == L and x > L:
		error = True
		break
	if d == 'North' and x > c:
		error = True
		break
	if d == 'South' and x + c > L:
		error = True
		break
	if d == 'North':
		c -= x
	elif d == 'South':
		c += x
if error or c != 0:
	print('NO')
else:
	print('YES')


def main():
	n = int(input())
	ans = 'YES'
	pos = 0
	for i in range(n):
		(t, direction) = input().split()
		t = int(t)
		if pos == 0 and direction != 'South' or (pos == 20000 and direction != 'North'):
			ans = 'NO'
			break
		if direction == 'East' or direction == 'West':
			continue
		if direction == 'South':
			pos += t
			if pos > 20000:
				ans = 'NO'
				break
		else:
			pos -= t
			if pos < 0:
				ans = 'NO'
				break
	if pos != 0:
		ans = 'NO'
	print(ans)
main()


a = int(input())
pos = [0, 0]
for i in range(a):
	z = input().split()
	b = int(z[0])
	c = z[1]
	for j in range(b):
		if pos[0] == 0 and c != 'South':
			print('NO')
			quit()
		if pos[0] == 20000 and c != 'North':
			print('NO')
			quit()
		if c == 'South':
			pos[0] += 1
		if c == 'North':
			pos[0] -= 1
		if c == 'West':
			pos[1] += 1
		if c == 'East':
			pos[1] += 1
if pos[0] == 0:
	print('YES')
else:
	print('NO')


n = int(input())
cur = 0
flag = True
for i in range(n):
	(t, s) = input().split()
	t = int(t)
	if cur == 0 and s != 'South':
		flag = False
		print('NO')
		break
	if cur == 20000 and s != 'North':
		flag = False
		print('NO')
		break
	if s == 'North':
		if cur < t:
			print('NO')
			flag = False
			break
		else:
			cur -= t
	if s == 'South':
		if cur + t > 20000:
			print('NO')
			flag = False
			break
		else:
			cur += t
if flag:
	if cur == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
vertical = 0
correct = True
for _ in range(t):
	(dist, direction) = input().split()
	dist = int(dist)
	if vertical == 20000 and direction != 'North':
		correct = False
	elif vertical == 0 and direction != 'South':
		correct = False
	elif vertical > 20000 or vertical < 0:
		correct = False
	if direction == 'South':
		vertical += dist
	elif direction == 'North':
		vertical -= dist
if vertical == 0 and correct == True:
	print('YES')
else:
	print('NO')


(s, n, a) = (0, int(input()), 0)
for i in range(n):
	(t, d) = map(str, input().split())
	t = int(t)
	if not a and d[0] != 'S' or (a == 20000 and d[0] != 'N') or (d[0] == 'N' and a - t < 0) or (d[0] == 'S' and a + t > 20000):
		s = 1
	a += 0 if d not in 'NorthSouth' else t if d[0] == 'S' else -t
print('YES' if not (s or a) else 'NO')


n = int(input())
N = 0
for i in range(n):
	(dist, dire) = input().split()
	dist = int(dist)
	if dire == 'North':
		if N >= dist:
			N -= dist
		else:
			print('NO')
			break
	elif dire == 'South':
		if N + dist <= 20000:
			N += dist
		else:
			print('NO')
			break
	elif dire == 'East':
		if N == 0 or N == 20000:
			print('NO')
			break
	elif dire == 'West':
		if N == 0 or N == 20000:
			print('NO')
			break
	if i == n - 1:
		if N == 0:
			print('YES')
		else:
			print('NO')


import sys
n = int(input())
y = 0
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if y < 0 or y > 20000:
		print('NO')
		exit()
	if d[0] == 'N':
		y -= t
	elif d[0] == 'S':
		y += t
	elif y == 0 or y == 20000:
		print('NO')
		exit()
print('YES' if y == 0 else 'NO')


def NO():
	print('NO')
	exit()
n = int(input())
ver = 0
for _ in range(n):
	(t, d) = input().split(' ')
	t = int(t)
	if ver == 0 and d != 'South':
		NO()
	if ver == 20000 and d != 'North':
		NO()
	if d == 'South':
		ver += t
	if d == 'North':
		ver -= t
	if ver < 0:
		NO()
	if ver > 20000:
		NO()
if ver != 0:
	NO()
print('YES')


def codeforces(path):
	pos_y = 0
	for (dist, direction) in path:
		if pos_y == 0 and direction != 'South' or (pos_y == 20000 and direction != 'North'):
			return 'NO'
		if direction == 'South':
			pos_y += dist
		elif direction == 'North':
			pos_y -= dist
		if pos_y < 0 or pos_y > 20000:
			return 'NO'
	if pos_y == 0:
		return 'YES'
	else:
		return 'NO'
steps = int(input())
path = []
for _ in range(steps):
	(dist, direction) = input().split()
	dist = int(dist)
	path.append((dist, direction))
print(codeforces(path))


import sys
n = int(input())
cur = 0
for _ in range(n):
	(a, b) = input().split()
	a = int(a)
	if b == 'North':
		cur -= a
	elif b == 'South':
		cur += a
	elif cur == 0 and b != 'South':
		print('NO')
		return
	elif cur == 20000 and b != 'North':
		print('NO')
		return
	if not 0 <= cur <= 20000:
		print('NO')
		return
if cur != 0:
	print('NO')
else:
	print('YES')


n = int(input())

def solve(n):
	pos = 0
	for i in range(n):
		(km, direc) = input().split()
		km = int(km)
		if pos == 0 and direc != 'South':
			print('NO')
			return
		elif pos == 20000 and direc != 'North':
			print('NO')
			return
		elif direc == 'South':
			pos += km
			if pos > 20000:
				print('NO')
				return
		elif direc == 'North':
			pos -= km
			if pos < 0:
				print('NO')
				return
	if pos == 0:
		print('YES')
	else:
		print('NO')
solve(n)


def do():
	n = int(input())
	fromN = 0
	for i in range(n):
		(l, d) = map(str, input().split())
		l = int(l)
		if fromN == 0 and d[0] in 'NEW':
			return 'NO'
		if fromN == 20000 and d[0] in 'SEW':
			return 'NO'
		if d[0] in 'EW':
			continue
		if d[0] == 'N':
			fromN -= l
		else:
			fromN += l
		if fromN < 0 or fromN > 20000:
			return 'NO'
	if fromN == 0:
		return 'YES'
	return 'NO'
print(do())


n = int(input())
flag = True
loc = 0
for _ in range(n):
	inp = input().split()
	if loc == 0 and inp[1] != 'South':
		flag = False
	if loc == 20000 and inp[1] != 'North':
		flag = False
	if inp[1] == 'North':
		if int(inp[0]) <= loc:
			loc = loc - int(inp[0])
		else:
			flag = False
	if inp[1] == 'South':
		if int(inp[0]) + loc <= 20000:
			loc = loc + int(inp[0])
		else:
			flag = False
if loc != 0:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


from sys import exit
n = int(input())
directions = []
for _ in range(n):
	(dist, direction) = input().split()
	dist = int(dist)
	directions.append((dist, direction))
location = 0
for (dist, direction) in directions:
	if location == 0 and direction != 'South':
		print('NO')
		exit(0)
	if location == 20000 and direction != 'North':
		print('NO')
		exit(0)
	if direction == 'South':
		location += dist
	if direction == 'North':
		location -= dist
	if location < 0 or location > 20000:
		print('NO')
		exit(0)
if location == 0:
	print('YES')
else:
	print('NO')


n = int(input())
y = 20000

def fail():
	print('NO')
	exit()
for _ in range(n):
	line = input().split()
	(t, d) = [int(line[0]), line[1]]
	if y == 20000 and d != 'South':
		fail()
	if y == 0 and d != 'North':
		fail()
	grad = None
	if d == 'South':
		if y - t < 0:
			fail()
		y -= t
	elif d == 'North':
		if y + t > 20000:
			fail()
		y += t
print('YES' if y == 20000 else 'NO')


q = int(input())
s = 20000
z = ['North', 'South']
x = ['West', 'East']
b = True
for j in range(0, q):
	a = list(input().split())
	if b:
		a[0] = int(a[0])
		if ((s == 0) | (s == 20000)) & (a[1] in x):
			b = False
		elif (s == 20000) & (a[1] == 'North'):
			b = False
		elif (s == 0) & (a[1] == 'South'):
			b = False
		elif a[1] in z:
			if a[1] == z[0]:
				s += a[0]
				if s > 20000:
					b = False
			else:
				s -= a[0]
				if s < 0:
					b = False
if b & (s != 20000):
	b = False
print('YES' if b else 'NO')


n = int(input())
cur = 0
flag = False
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d == 'North':
		flag |= cur < t
		cur -= t
	elif d == 'South':
		flag |= cur + t > 20000
		cur += t
	else:
		flag |= cur in (0, 20000)
flag |= cur != 0
print('YES' if not flag else 'NO')


n = int(input())
ans = 'YES'
p = 0
for _ in range(n):
	(t, d) = input().split()
	if d == 'South':
		p += int(t)
		if p > 20000:
			ans = 'NO'
			break
	elif d == 'North':
		p -= int(t)
		if p < 0:
			ans = 'NO'
			break
	elif abs(p) % 20000 == 0:
		ans = 'NO'
		break
if p != 0:
	ans = 'NO'
print(ans)


n = int(input())
a = [0]
l = []
res = 0
ans = 'YES'
for i in range(n):
	l.append(input().split())
for i in l:
	if i[1] == 'North':
		res -= int(i[0])
		if res < 0:
			ans = 'NO'
			break
	elif i[1] == 'South':
		res += int(i[0])
		if res > 20000:
			ans = 'NO'
			break
	elif res == 0 or res == 20000:
		ans = 'No'
		break
if res == 0 and ans == 'YES':
	print(ans)
else:
	print('NO')


n = int(input())
steps = []
(x, y) = (0, 0)
for _ in range(n):
	s = input().split(' ')
	steps.append((int(s[0]), s[1]))
result = ''
for s in steps:
	if y == 0 and s[1] != 'South' or y > 0:
		result = 'NO'
		break
	if y == -20000 and s[1] != 'North' or y < -20000:
		result = 'NO'
		break
	if s[0] > 20000 and s[1] in ['North', 'South']:
		result = 'NO'
		break
	if s[1] == 'North':
		y += s[0]
	elif s[1] == 'South':
		y -= s[0]
if result == 'NO':
	print('NO')
elif y == 0:
	print('YES')
else:
	print('NO')


n = int(input())
cur = 0
for i in range(n):
	s = input().split()
	if cur == 0 and s[1] != 'South' or (cur == 20000 and s[1] != 'North'):
		print('NO')
		exit()
	if s[1] == 'South':
		cur += int(s[0])
		if cur > 20000:
			print('NO')
			exit()
	elif s[1] == 'North':
		cur -= int(s[0])
		if cur < 0:
			print('NO')
			exit()
	if i == n - 1 and cur != 0:
		print('NO')
		exit()
print('YES')


def solve(ls):
	l = [0, 0]
	pos = 'North'
	for (a, b) in ls:
		if pos == 'North' and b != 'South':
			return False
		if pos == 'South' and b != 'North':
			return False
		if b == 'South':
			if a > 20000 or a < 0:
				return False
			l[0] += a
			if l[0] > 20000:
				return False
			pos = ''
			if l[0] == 20000:
				pos = 'South'
		elif b == 'North':
			if a > 20000 or a < 0:
				return False
			l[0] -= a
			if l[0] < 0:
				return False
			pos = ''
			if l[0] == 0:
				pos = 'North'
	if l[0] == 0:
		return True
	return False
ls = []
t = int(input())
while t:
	(a, b) = input().split()
	a = int(a)
	ls.append([a, b])
	t -= 1
x = solve(ls)
print('YES' if x else 'NO')


__author__ = 'yiyi'
n = int(input())
flag = True
R = 20000
dN = 0
dS = R
for i in range(n):
	(n, ss) = input().split()
	n = int(n)
	if ss == 'East' or ss == 'West':
		if dN == 0 or dS == 0:
			flag = False
			break
		continue
	elif ss == 'South':
		if dS == 0 or dS - n < 0:
			flag = False
			break
		else:
			dN += n
			dS -= n
	elif ss == 'North':
		if dN == 0 or dN - n < 0:
			flag = False
			break
		else:
			dN -= n
			dS += n
if dN != 0 or dS != R:
	flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
curr = 0
for i in range(n):
	(dist, dir) = map(str, input().split())
	dist = int(dist)
	if dir == 'North':
		if curr == 0 or curr - dist < 0:
			print('NO')
			exit()
		curr -= dist
	elif dir == 'East':
		if curr == 0 or curr == 20000:
			print('NO')
			exit()
	elif dir == 'West':
		if curr == 0 or curr == 20000:
			print('NO')
			exit()
	else:
		if curr == 20000 or curr + dist > 20000:
			print('NO')
			exit()
		curr += dist
if curr == 0:
	print('YES')
else:
	print('NO')


import math

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
n = int(input())
pos = 0
s_pos = 20000
for _ in range(n):
	(t, dir) = input().split()
	t = int(t)
	if pos == 0 and dir != 'South':
		print('NO')
		exit(0)
	if pos == s_pos and dir != 'North':
		print('NO')
		exit(0)
	if dir == 'South':
		pos += t
		if pos > s_pos:
			print('NO')
			exit(0)
			pos = s_pos - (pos - s_pos)
	elif dir == 'North':
		pos -= t
		if pos < 0:
			print('NO')
			exit(0)
			pos = abs(pos)
if pos == 0:
	print('YES')
else:
	print('NO')


curr = 0
for _ in range(int(input())):
	s = input().split()
	if not curr % 40000 and s[1] != 'South':
		print('NO')
		exit(0)
	elif curr % 40000 == 20000 and s[1] != 'North':
		print('NO')
		exit(0)
	if s[1] in ['North']:
		curr -= int(s[0])
	elif s[1] in ['South']:
		curr += int(s[0])
	if curr > 20000 or curr < 0:
		print('NO')
		exit(0)
if curr % 40000:
	print('NO')
	exit(0)
print('YES')


n = int(input())
dx = 0
dy = 0
for i in range(n):
	(k, s) = input().split()
	k = int(k)
	if s == 'North':
		dy -= k
		if dy < 0:
			print('NO')
			exit()
	elif s == 'South':
		dy += k
		if dy > 20000:
			print('NO')
			exit()
	elif s == 'East':
		dx += k
		dx %= 20000
		if dy <= 0 or dy >= 20000:
			print('NO')
			exit()
	else:
		dx -= k
		if dx < 0:
			dx = -(abs(dx) % 20000)
		else:
			dx %= 20000
		if dy <= 0 or dy >= 20000:
			print('NO')
			exit()
	if i == n - 1:
		if dy != 0:
			print('NO')
			exit()
print('YES')


n = int(input())
current = 0
flag = 0
valid = ['North', 'South']
for i in range(n):
	a = input()
	if flag == -1:
		continue
	if current % 20000 == 0:
		if a.split(' ')[1] not in valid:
			flag = -1
	if a.split(' ')[1] == 'South':
		current += int(a.split(' ')[0])
	elif a.split(' ')[1] == 'North':
		current -= int(a.split(' ')[0])
	if current < 0 or current > 20000:
		flag = -1
if flag == -1:
	print('No')
elif current == 0:
	print('Yes')
else:
	print('No')


def fail():
	print('NO')
	exit()
read = lambda : map(int, input().split())
n = int(input())
h = 0
nr = 'North'
st = 'South'
ws = 'West'
es = 'East'
Max = 20000
for i in range(n):
	(t, dir) = input().split()
	t = int(t)
	if h == 0 and dir != st:
		fail()
	if h == Max and dir != nr:
		fail()
	h += t * {st: 1, nr: -1, es: 0, ws: 0}[dir]
	if h > Max or h < 0:
		fail()
if h:
	fail()
print('YES')


n = int(input())
failed = False
total_dist = 0
for i in range(n):
	(dist, direction) = input().split()
	if direction == 'East' or direction == 'West':
		if total_dist == 0 or total_dist == 20000:
			failed = True
			break
		continue
	dist = int(dist)
	if direction == 'North':
		total_dist -= dist
	else:
		total_dist += dist
	if total_dist < 0 or total_dist > 20000:
		failed = True
		break
if failed:
	print('NO')
elif total_dist == 0:
	print('YES')
else:
	print('NO')


n = int(input())
pos = 0
directions = {'South': 1, 'North': -1}
for _ in range(n):
	inst = input().split()
	if pos == 0:
		if inst[1] != 'South':
			print('NO')
			exit()
	elif pos == 20000:
		if inst[1] != 'North':
			print('NO')
			exit()
	if inst[1] not in directions.keys():
		continue
	pos += int(inst[0]) * directions[inst[1]]
	if pos > 20000 or pos < 0:
		print('NO')
		exit()
if pos == 0:
	print('YES')
else:
	print('NO')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return mt.sqrt((x - c) ** 2 + (y - d) ** 2)

def circle(x1, y1, x2, y2, r1, r2):
	distSq = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
	if distSq + r2 <= r1:
		return True
	else:
		return False
n = I()
x = 0
d = 0
for i in range(n):
	(dis, dire) = input().split()
	dis = int(dis)
	if dire[0] == 'S':
		x += dis
	if dire[0] == 'N':
		x -= dis
	if x == 0 or x == 20000:
		if dire[0] == 'E' or dire[0] == 'W':
			print('NO')
			d = 1
			break
	if x < 0:
		print('NO')
		d = 1
		break
	if x > 20000:
		print('NO')
		d = 1
		break
if x == 0 and d == 0:
	print('YES')
elif d == 0:
	print('NO')


import math
n = int(input())
fi = 0
theta = 0
flag = True
for n in range(n):
	row = [x for x in input().split()]
	dist = int(row[0])
	napr = row[1]
	if fi == 0 and napr != 'South' or fi < 0:
		flag = False
		break
	if fi == 20000 and napr != 'North' or fi > 20000:
		flag = False
		break
	if napr == 'South':
		fi += dist
	elif napr == 'North':
		fi -= dist
if flag and fi == 0:
	print('YES')
else:
	print('NO')


n = int(input())
acc = 0
breakrule = False
for i in range(n):
	(n, d) = input().split(' ')
	if acc == 0 and d != 'South':
		breakrule = True
	if acc == 20000 and d != 'North':
		breakrule = True
	if d == 'South':
		acc += int(n)
	if d == 'North':
		acc -= int(n)
	if acc > 20000 or acc < 0:
		breakrule = True
if acc != 0 or breakrule:
	print('NO')
else:
	print('YES')


n = int(input())
b = 0
currentPos = 0
for i in range(n):
	(k, dir) = input().split()
	k = int(k)
	if currentPos == 0 and dir != 'South':
		b = 1
	elif currentPos == 20000 and dir != 'North':
		b = 1
	elif dir == 'North' and currentPos - k < 0:
		b = 1
	elif dir == 'South' and currentPos + k > 20000:
		b = 1
	elif dir == 'North':
		currentPos -= k
	elif dir == 'South':
		currentPos += k
if currentPos != 0:
	b = 1
if b == 0:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
n = int(input())
curpos = 20000
dirlist = [input().strip().split() for i in range(n)]
for i in dirlist:
	miles = int(i[0])
	direction = i[1]
	if direction == 'East' or direction == 'West':
		if curpos == 0 or curpos == 20000:
			print('NO')
			sys.exit()
	elif direction == 'North':
		if miles + curpos > 20000:
			print('NO')
			sys.exit()
		else:
			curpos = miles + curpos
	elif direction == 'South':
		if curpos - miles < 0:
			print('NO')
			sys.exit()
		else:
			curpos = curpos - miles
if curpos != 20000:
	print('NO')
else:
	print('YES')


s = 0
for i in range(int(input())):
	(t, d) = input().split()
	k = (d[0] == 'S') - (d[0] == 'N')
	if s % 20000 == k == 0:
		s = 1
		break
	s += k * int(t)
	if s < 0 or s > 20000:
		break
print('NO' if s else 'YES')


n = int(input())
x = 0

def go(y):
	if y // 20000 % 2 == 1:
		return 20000 - y % 20000
	else:
		return y % 20000
for i in range(n):
	s = input().split(' ')
	t = int(s[0])
	if x == 0:
		if s[1] == 'South':
			if x + t <= 20000:
				x = go(x + t)
				continue
			else:
				x = 7
				break
		else:
			x = 7
			break
	if x == 20000:
		if s[1] == 'North':
			if x - t >= 0:
				x = go(abs(x - t))
				continue
			else:
				x = 7
				break
		else:
			x = 7
			break
	if x != 0 and x != 20000:
		if s[1] == 'South':
			if x + t <= 20000:
				x = go(x + t)
			else:
				x = 7
				break
		if s[1] == 'North':
			if x - t >= 0:
				x = go(abs(x - t))
			else:
				x = 7
				break
if x == 0:
	print('YES')
else:
	print('NO')


import math
d = {'North': 'South', 'South': 'North'}
n = int(input())
l = []
p = 1
for i in range(n):
	(ti, diri) = [item for item in input().split()]
	if diri in ['North', 'South'] and int(ti) > 20000:
		if p == 1:
			print('NO')
		p = 0
	l.append([ti, diri])
if l[0][1] != 'South':
	if p == 1:
		print('NO')
	p = 0
elif l[-1][1] != 'North':
	if p == 1:
		print('NO')
	p = 0
else:
	c = 0
	for i in range(n):
		if l[i][1] == 'North':
			c -= int(l[i][0])
		elif l[i][1] == 'South':
			c += int(l[i][0])
		if c < 0 or c > 20000:
			if p == 1:
				print('NO')
			p = 0
		if c in [20000, 0] and i != n - 1 and (l[i][1] in ['North', 'South']):
			if l[i + 1][1] != d[l[i][1]]:
				if p == 1:
					print('NO')
				p = 0
	if c != 0:
		if p == 1:
			print('NO')
		p = 0
if p == 1:
	print('YES')


n = int(input())
L = []
for i in range(n):
	L.append(input().split())
	L[-1][0] = int(L[-1][0])
dist = 0
valid = True
for (x, y) in L:
	if y == 'North':
		dist -= x
	elif y == 'South':
		dist += x
	elif dist in (0, 20000):
		valid = False
		break
	if dist < 0 or dist > 20000:
		valid = False
		break
if valid and dist == 0:
	print('YES')
else:
	print('NO')


def main():
	north = True
	south = False
	dirs = ['North', 'South', 'West', 'East']
	len = 0
	n = int(input())
	i = 0
	a = []
	dr = []
	while i < n:
		str_ = input()
		aa = str_.split(' ')
		a.append(int(aa[0]))
		dr.append(aa[1])
		i += 1
	i = 0
	while i < n:
		if north and (dr[i] == dirs[0] or dr[i] == dirs[2] or dr[i] == dirs[3]):
			print('NO')
			return None
		elif south and (dr[i] == dirs[1] or dr[i] == dirs[2] or dr[i] == dirs[3]):
			print('NO')
			return None
		elif dr[i] == dirs[0]:
			south = False
			len -= a[i]
			if len == 0:
				north = True
			elif len < 0:
				print('NO')
				return None
		elif dr[i] == dirs[1]:
			north = False
			len += a[i]
			if len == 20000:
				south = True
			elif len > 20000:
				print('NO')
				return None
		i += 1
	if north:
		print('YES')
	else:
		print('NO')
main()


cv = 20000
f = True
n = int(input())
for i in range(n):
	(x, s) = input().split()
	x = int(x)
	if s in ['East', 'West'] and (cv == 20000 or cv == 0):
		f = False
	if s == 'North':
		cv += x
	if s == 'South':
		cv -= x
	if cv < 0 or cv > 20000:
		f = False
if cv != 20000:
	f = False
print('Yes' if f else 'No')


n = int(input())
l = []
for i in range(n):
	(a, b) = map(str, input().split())
	a = int(a)
	c = [a, b]
	l.append(c)
milles = 0
for i in range(n):
	dist = l[i][0]
	direcc = l[i][1]
	if direcc == 'South':
		milles = milles + dist
	elif direcc == 'North':
		milles = milles - dist
	elif (direcc == 'West' or direcc == 'East') and (milles == 0 or milles == 20000):
		print('NO')
		exit(0)
	if milles < 0 or milles > 2 * 10 ** 4:
		print('NO')
		exit(0)
if milles != 0:
	print('NO')
else:
	print('YES')


def main():
	MAXH = 20000
	n = int(input())
	h = 0
	for i in range(n):
		(dist, d) = input().split()
		dist = int(dist)
		if d in ('West', 'East'):
			if h == 0 or h == MAXH:
				print('NO')
				return
			continue
		if d == 'North':
			h -= dist
		elif d == 'South':
			h += dist
		if h < 0 or h > MAXH:
			print('NO')
			return
	print('YES' if h == 0 else 'NO')
main()


from math import sin
n = int(input())
c = 0
R = 20000
eps = 1e-06
for i in range(n):
	(t, d) = [j for j in input().split(' ')]
	t = int(t)
	if d == 'South':
		if abs(c - 1) < eps or t > 20000:
			c = 1
			break
		c += t / R
	elif d == 'North':
		if c < eps or t > 20000:
			c = 1
			break
		c -= t / R
	elif c < eps or abs(c - 1) < eps:
		c = 1
		break
	if c > 1 + eps or c < -eps:
		c = 1
		break
if c < eps:
	print('YES')
else:
	print('NO')


r = 0
a = ''
for i in range(int(input())):
	(ti, diri) = map(str, input().split())
	ti = int(ti)
	if r == 0 and diri != 'South':
		a = 'NO'
		break
	if r == 20000 and diri != 'North':
		a = 'NO'
		break
	if diri == 'South':
		r += ti
	if diri == 'North':
		r -= ti
	if r > 20000:
		a = 'NO'
		break
	if r < 0:
		a = 'NO'
		break
if r == 0 and a != 'NO':
	print('YES')
else:
	print('NO')


n = int(input())
directions = []
pos = 0
for a in range(n):
	directions.append(input())
if n == 1:
	print('NO')
else:
	for a in range(n):
		direc = directions[a].split()
		if direc[1] == 'East' or direc[1] == 'West':
			if pos == 0 or pos == 20000:
				print('NO')
				break
			if a == n - 1:
				if pos == 0:
					print('YES')
				else:
					print('NO')
			continue
		elif direc[1] == 'North':
			if pos - int(direc[0]) < 0:
				print('NO')
				break
			pos -= int(direc[0])
			if pos == 0 and a == 0:
				print('YES')
				break
			if a == n - 1:
				if pos != 0:
					print('NO')
					break
				else:
					print('YES')
					break
		elif direc[1] == 'South':
			if pos + int(direc[0]) > 20000:
				print('NO')
				break
			pos += int(direc[0])
			if a == n - 1:
				print('NO')
				break
			if a == n - 1:
				if pos == 0:
					print('YES')
					break
				else:
					print('NO')
					break


x = 0
for i in range(int(input())):
	(d, w) = input().split()
	d = int(d)
	if w == 'North':
		x -= d
	elif w == 'South':
		x += d
	elif x % 20000 == 0:
		print('NO')
		quit()
	if x < 0 or x > 20000:
		print('NO')
		quit()
print('YES' if x == 0 else 'NO')


n = int(input())
dist = []
d = []
sum = 0
flag = 0
for x in range(0, n):
	(m, p) = input().strip().split(' ')
	dist.append(int(m))
	d.append(p)
for x in range(0, n):
	if sum == 0 and d[x] != 'South' or (sum == 20000 and d[x] != 'North') or sum > 20000 or (sum < 0):
		flag = 1
		break
	else:
		if d[x] == 'South':
			sum = sum + dist[x]
		if d[x] == 'North':
			sum = sum - dist[x]
if sum == 0 and flag == 0:
	print('YES')
else:
	print('NO')


Earth = 20000
T = int(input())
pos = 0
bad = False
for t in range(T):
	(v, p) = input().split()
	v = int(v)
	if p == 'South':
		pos += v
		if pos < 0 or pos > Earth:
			bad = True
	elif p == 'North':
		pos -= v
		if pos < 0 or pos > Earth:
			bad = True
	elif p == 'East' or p == 'West':
		if pos == 0 or pos == Earth:
			bad = True
if pos:
	bad = True
if bad:
	print('NO')
else:
	print('YES')


N = int(input())
l = 0
f = 0
for i in range(N):
	(t, k) = input().split(' ')
	t = int(t)
	if l == 0 and k != 'South':
		f = 1
		break
	elif l == 20000 and k != 'North':
		f = 1
		break
	if k == 'North':
		l -= t
	elif k == 'South':
		l += t
	if l < 0 or l > 20000:
		f = 1
		break
if f == 0 and l == 0:
	print('YES')
else:
	print('NO')


def NO():
	print('NO')
	exit(0)
n = int(input())
north = 0
west = 0
for i in range(n):
	a = input().split()
	d = int(a[0])
	k = a[1]
	if k == 'North':
		north -= d
		if north < 0:
			NO()
	elif k == 'South':
		north += d
		if north > 20000:
			NO()
	elif north % 20000 == 0:
		NO()
if north != 0:
	NO()
print('YES')


n = int(input())
south = 0
no = False
for _ in range(n):
	(length, direction) = input().split()
	if not south and direction != 'South' or (south == 20000 and direction != 'North'):
		no = True
		break
	if direction == 'South':
		south += int(length)
		if south > 20000:
			no = True
			break
	elif direction == 'North':
		south -= int(length)
		if south < 0:
			no = True
			break
if south:
	no = True
print('NO' if no else 'YES')


n = int(input())
v = 0
f = True
for i in range(n):
	(t, d) = str(input()).split()
	t = int(t)
	if d == 'South':
		if v == 20000:
			f = False
			break
		v += t
	elif d == 'North':
		if v == 0:
			f = False
			break
		v -= t
	elif v in (0, 20000):
		f = False
		break
	if v > 20000 or v < 0:
		f = False
		break
if v == 0 and f:
	print('YES')
else:
	print('NO')


def move(a, b, d):
	if abs(a) == 10000 and d[0] not in 'SN':
		return -10001
	if d[0] == 'S':
		return a - b
	if d[0] == 'N':
		return a + b
	return a
bo = True
r = 10000
for _ in range(int(input())):
	(a, b) = input().split()
	r = move(r, int(a), b)
	if abs(r) > 10000:
		bo = False
		break
if r != 10000:
	bo = False
print('NO YES'.split()[bo])


n = int(input())
y = 0
maxlen = 20000
for i in range(n):
	raw = input().split()
	cur = int(raw[0])
	dir = raw[1]
	if y == 0 and dir != 'South':
		print('NO')
		quit()
	if y == maxlen and dir != 'North':
		print('NO')
		quit()
	if dir == 'South':
		y += cur
	elif dir == 'North':
		y -= cur
	if y < 0 or y > maxlen:
		print('NO')
		quit()
if y == 0:
	print('YES')
else:
	print('NO')


x = 0
dir = {'South': 1, 'North': -1}
for _ in range(int(input())):
	m = input().split()
	if x == 0 and m[1] != 'South' or (x == 20000 and m[1] != 'North'):
		print('NO')
		exit(0)
	try:
		n = x + int(m[0]) * dir[m[1]]
	except:
		continue
	if x and n < 0 or abs(n) > 20000:
		print('NO')
		exit(0)
	x = abs(n)
print('NO') if x else print('YES')


def solve():
	y = 0
	for _ in range(int(input())):
		(l, d) = input().split()
		l = int(l)
		if y == 0 and d[0] != 'S':
			return 'NO'
		if y == 20000 and d[0] != 'N':
			return 'NO'
		if d[0] in ['E', 'W']:
			continue
		y += l if d[0] == 'S' else -l
		if y < 0 or y > 20000:
			return 'NO'
	return 'NO' if y else 'YES'
print(solve())


def solve():
	n = int(input())
	y = 0
	for _ in range(n):
		(dist, direction) = input().split()
		dist = int(dist)
		if direction == 'South':
			y += dist
		elif direction == 'North':
			y -= dist
		elif y == 0 or y == 20000:
			return 'NO'
		if y < 0 or y > 20000:
			return 'NO'
	if y != 0:
		return 'NO'
	return 'YES'

def __starting_point():
	print(solve())
__starting_point()


n = int(input())
i = [input().split() for _ in range(n)]
d = 0
for x in i:
	if d == 0 and x[1] != 'South':
		print('NO')
		break
	elif d == -20000 and x[1] != 'North':
		print('NO')
		break
	elif x[1] == 'North' and int(x[0]) + d > 0:
		print('NO')
		break
	elif x[1] == 'South' and d - int(x[0]) < -20000:
		print('NO')
		break
	elif x[1] == 'South':
		d -= int(x[0])
	elif x[1] == 'North':
		d += int(x[0])
else:
	print('YES' if d == 0 else 'NO')


n = int(input())
x = 0
ans = True
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d == 'South' and x + t > 20000:
		ans = False
	elif d == 'North' and x - t < 0:
		ans = False
	elif (d == 'West' or d == 'East') and (x == 0 or x == 20000):
		ans = False
	if d == 'South':
		x += t
	elif d == 'North':
		x -= t
if x != 0:
	ans = False
if ans:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	o = 0
	for i in range(n):
		(t, s) = input().split()
		t = int(t)
		if s == 'East' or s == 'West':
			if o == 0 or o == 20000:
				print('NO')
				return
		elif s == 'North':
			o -= t
			if o < 0:
				print('NO')
				return
		else:
			o += t
			if o > 20000:
				print('NO')
				return
	if o == 0:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
y = 10000
for i in range(n):
	(l, d) = input().split()
	l = int(l)
	if y == 10000:
		if d != 'South':
			print('NO')
			exit()
	elif y == -10000:
		if d != 'North':
			print('NO')
			exit()
	if d == 'North':
		y += l
	elif d == 'South':
		y -= l
	if y > 10000 or y < -10000:
		print('NO')
		exit()
if y == 10000:
	print('YES')
else:
	print('NO')


dic = {'South': 1, 'North': -1, 'East': 0, 'West': 0}
loop = int(input())
summ = 0
ans = 'YES'
for i in range(loop):
	(value, pool) = input().split()
	value = int(value)
	summ += dic[pool] * value
	if summ < 0 or summ > 20000:
		ans = 'NO'
		break
	if dic[pool] == 0 and (summ == 0 or summ == 20000):
		ans = 'NO'
		break
if summ == 0 and ans == 'YES':
	print('YES')
else:
	print('NO')


MAX = 20000
n = int(input())
d = 0
ok = 1
for i in range(n):
	(len, dir) = input().split(' ')
	if dir in ('East', 'West'):
		if d == 0 or d == MAX:
			ok = 0
	elif dir == 'South':
		d += int(len)
	else:
		d -= int(len)
	if d < 0 or d > MAX:
		ok = 0
if d != 0:
	ok = 0
if ok:
	print('YES')
else:
	print('NO')


n = int(input())
s = 0
m = 20000
ans = 'YES'
for i in range(n):
	a = input().split()
	c = int(a[0])
	if s == 0 and a[1] != 'South':
		ans = 'NO'
	if s == m and a[1] != 'North':
		ans = 'NO'
	if s < 0 or s > m:
		ans = 'NO'
	if a[1] == 'North':
		s -= c
	if a[1] == 'South':
		s += c
if s != 0:
	ans = 'NO'
print(ans)


(h, o) = (0, 1)
for i in range(int(input())):
	(t, d) = input().split()
	if d[0] in 'NS':
		h += (-int(t), int(t))[d[0] == 'S']
	if d[0] in 'WE' and h in (0, 20000) or not 0 <= h <= 20000:
		o = 0
print(('NO', 'YES')[o * (h == 0)])


n = int(input())
ls = 20000
isOnNorth = True
isOnSouth = False
for i in range(n):
	temp = input().split()
	temp[0] = int(temp[0])
	if isOnNorth and temp[1] != 'South':
		print('NO')
		exit(0)
	elif isOnSouth and temp[1] != 'North':
		print('NO')
		exit(0)
	if temp[1] == 'North':
		ls += temp[0]
	elif temp[1] == 'South':
		ls -= temp[0]
	else:
		continue
	if ls > 20000 or ls < 0:
		print('NO')
		exit(0)
	if ls == 20000:
		isOnNorth = True
	else:
		isOnNorth = False
	if ls == 0:
		isOnSouth = True
	else:
		isOnSouth = False
if isOnNorth:
	print('YES')
else:
	print('NO')


n = int(input())
pos = 0
for i in range(n):
	(t, drc) = input().split()
	t = int(t)
	drc = str(drc)
	if pos == 0 and drc != 'South':
		print('NO')
		exit()
	if pos == 20000 and drc != 'North':
		print('NO')
		exit()
	if drc == 'South' and pos != 20000:
		if t > 20000 - pos:
			print('NO')
			exit()
		else:
			pos += t
	if drc == 'North' and pos != 0:
		if t > pos:
			print('NO')
			exit()
		else:
			pos -= t
if pos == 0:
	print('YES')
else:
	print('NO')


n = int(input())
y = 0
for i in range(n):
	temp = input().split()
	(a, d) = (int(temp[0]), temp[1])
	if y == 0 and d != 'South' or (y == 20000 and d != 'North') or (not 0 <= y <= 20000):
		print('NO')
		exit()
	elif d == 'South':
		y += a
	elif d == 'North':
		y -= a
print('YES') if y == 0 else print('NO')


n = int(input())
arr = []
a = 0
x = 0
for i in range(n):
	arr.append([j for j in input().split()])
	arr[i][0] = int(arr[i][0])
for i in range(n):
	if x == 20000:
		if arr[i][1] != 'North':
			break
	if x == 0:
		if arr[i][1] != 'South':
			a = 1
			break
	if arr[i][1] == 'South':
		x = x + arr[i][0]
	if arr[i][1] == 'North':
		x = x - arr[i][0]
	if x < 0 or x > 20000:
		a = 1
		break
if a == 1:
	print('NO')
	exit()
if x == 0:
	print('YES')
else:
	print('NO')


n = int(input())
w = 0
e = 0
y = 0
r = 0
for i in range(n):
	(d, v) = input().split(' ')
	d = int(d)
	if v == 'North':
		y -= d
	elif v == 'South':
		y += d
	elif (v == 'West' or v == 'East') and (y == 0 or y == 20000):
		r = -1
	if y < 0 or y > 20000:
		r = -1
if r == 0 and y == 0:
	print('YES')
else:
	print('NO')


n = int(input())
position = 20000
b = True
for _ in range(n):
	s = input().split()
	(t, dir) = (int(s[0]), s[1])
	if position == 20000 and dir != 'South' or (position == 0 and dir != 'North'):
		b = False
		break
	if dir == 'South':
		position -= t
	elif dir == 'North':
		position += t
	if position < 0 or position > 20000:
		b = False
		break
print('YES' if b and position == 20000 else 'NO')


n = int(input())
s = list()
for i in range(n):
	s.append(input().split())
	s[i][0] = int(s[i][0])
msg = 'Yes'
length = 0
if s[0][1] != 'South':
	msg = 'No'
for i in range(n):
	if s[i][1] == 'North':
		length -= s[i][0]
	if s[i][1] == 'South':
		length += s[i][0]
	if s[n - 1][1] != 'North':
		msg = 'No'
	if length == 20000 or length == 0:
		if i != n - 1:
			if s[i][1] == 'North' and s[i + 1][1] != 'South':
				msg = 'No'
			if s[i + 1][1] != 'North' and s[i][1] == 'South':
				msg = 'No'
	if length > 20000 or length < 0:
		msg = 'No'
	if i == n - 1 and s[i][1] != 'North':
		msg = 'No'
if length != 0:
	msg = 'No'
print(msg)


n = int(input())
coord = 0
for i in range(n):
	(ai, bi) = input().split()
	ai = int(ai)
	if coord == 0 and bi != 'South':
		print('NO')
		break
	if coord == 20000 and bi != 'North':
		print('NO')
		break
	if bi == 'North':
		coord -= ai
		if coord < 0:
			print('NO')
			break
	elif bi == 'South':
		coord += ai
		if coord > 20000:
			print('NO')
			break
else:
	if coord != 0:
		print('NO')
	else:
		print('YES')


c = 0
for i in range(int(input())):
	(t, d) = input().split()
	t = int(t)
	if d == 'South':
		c += t
	elif d == 'North':
		c -= t
	elif not c or c == 20000:
		print('NO')
		exit(0)
	if c < 0 or c > 20000:
		print('NO')
		exit(0)
if c:
	print('NO')
else:
	print('YES')


(s, a) = (0, 0)
for _ in ' ' * int(input()):
	(t, d) = map(str, input().split())
	t = int(t)
	if not a and d[0] != 'S' or (a == 20000 and d[0] != 'N') or (d[0] == 'N' and a - t < 0) or (d[0] == 'S' and a + t > 20000):
		s = 1
		break
	a += 0 if d not in 'NorthSouth' else t if d[0] == 'S' else -t
print('YES' if not (s or a) else 'NO')


n = int(input())
dn = 0
valid = 'YES'
for i in range(n):
	(d, s) = input().split()
	d = int(d)
	if s == 'North':
		if d > dn:
			valid = 'NO'
		else:
			dn = dn - d
	elif s == 'South':
		if d + dn > 20000:
			valid = 'NO'
		else:
			dn = dn + d
	elif dn == 0 or dn == 20000:
		valid = 'NO'
if dn != 0:
	valid = 'NO'
print(valid)


n = int(input())
loc = 0
for i in range(n):
	(dist, direct) = input().split()
	dist = int(dist)
	if loc == 0 and direct != 'South' or (loc == 20000 and direct != 'North'):
		print('NO')
		break
	if direct == 'South':
		loc += dist
	elif direct == 'North':
		loc -= dist
	if loc < 0 or loc > 20000:
		print('NO')
		break
else:
	print('YES' if loc == 0 else 'NO')


I = lambda : list(map(int, input().split()))
n = I()[0]
(t, dir) = [[] for _ in range(2)]
for _ in range(n):
	(_t, _dir) = input().split()
	t.append(int(_t))
	dir.append(_dir)
position = 0
flag = True
for i in range(n):
	_t = t[i]
	_dir = dir[i]
	if position == 0 and _dir != 'South':
		flag = False
		break
	if position == 20000 and _dir != 'North':
		flag = False
		break
	position += _t * (1 * (_dir == 'South') - 1 * (_dir == 'North'))
	if position > 20000 or position < 0:
		flag = False
		break
if flag and position == 0:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	lat = 0
	valid = True
	for _ in range(n):
		(amount, direction) = input().split()
		amount = int(amount)
		if lat == 0 and direction[0] != 'S':
			valid = False
		elif lat == 20000 and direction[0] != 'N':
			valid = False
		if direction[0] == 'S':
			lat += amount
		elif direction[0] == 'N':
			lat -= amount
		if 0 > lat or lat > 20000:
			valid = False
	print('YES' if valid and lat == 0 else 'NO')
main()


py = 0
ans = ''
n = int(input())
for i in range(n):
	mess = input().split()
	number = int(mess[0])
	napr = mess[1]
	if py == 20000 and napr != 'North':
		ans = 'NO'
	if py == 0 and napr != 'South':
		ans = 'NO'
	if py > 20000 or py < 0:
		ans = 'NO'
	if napr == 'South':
		py += number
	if napr == 'North':
		py -= number
if ans != 'NO' and py == 0:
	ans = 'YES'
else:
	ans = 'NO'
print(ans)


N = 0
n = int(input())
for i in range(n):
	if N > 20000 or N < 0:
		print('NO')
		break
	(a, b) = input().split()
	if b == 'North':
		N -= int(a)
	elif b == 'South':
		N += int(a)
	elif N == 0 or N == 20000:
		print('NO')
		break
else:
	if N == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
pos = []
for i in range(n):
	(t, s) = input().split()
	pos.append([int(t), s])
dist = 0
flag = 0
for i in range(n):
	move = pos[i][0]
	direction = pos[i][1]
	if direction == 'South':
		if dist + move <= 20000:
			dist += move
		else:
			flag = 1
			break
	if direction == 'North':
		if dist - move >= 0:
			dist -= move
		else:
			flag = 1
			break
	if direction == 'East':
		if dist == 0 or dist == 20000:
			flag = 1
			break
	if direction == 'West':
		if dist == 0 or dist == 20000:
			flag = 1
			break
if flag == 0 and dist == 0:
	print('YES')
else:
	print('NO')


import pdb
N = int(input())

def poles(N):
	South = 0
	North = 1
	East = 2
	West = 3
	NorthPole = 0
	SouthPole = 20000
	directions = ['South', 'North', 'East', 'West']
	position = 0
	for _ in range(N):
		(steps, direction) = input().split()
		steps = int(steps)
		if direction == directions[East] or direction == directions[West]:
			if position != NorthPole and position != SouthPole:
				continue
			else:
				return 'NO'
		if direction == directions[South]:
			if steps + position > SouthPole:
				return 'NO'
			else:
				position += steps
		if direction == directions[North]:
			if position - steps < NorthPole:
				return 'NO'
			else:
				position -= steps
	if position == NorthPole:
		return 'YES'
	else:
		return 'NO'
print(poles(N))


def main():
	n = int(input())
	cur_pos = 0
	for _ in range(n):
		(t, d) = input().split()
		t = int(t)
		if cur_pos == 0 and d != 'South':
			print('NO')
			return
		if cur_pos == 20000 and d != 'North':
			print('NO')
			return
		if d in ('West', 'East'):
			continue
		if t > 20000:
			print('NO')
			return
		if d == 'North':
			cur_pos -= t
		else:
			cur_pos += t
		if cur_pos < 0 or cur_pos > 20000:
			print('NO')
			return
	if cur_pos != 0:
		print('NO')
		return
	print('YES')
main()


n = int(input())
cor = 0
satis = True
for i in range(n):
	line = input().split()
	if line[1] == 'South':
		cor += int(line[0])
		if cor > 20000:
			satis = False
			break
	elif line[1] == 'North':
		cor -= int(line[0])
		if cor < 0:
			satis = False
			break
	elif cor == 20000 or cor == 0:
		satis = False
		break
if cor != 0:
	satis = False
if satis:
	print('YES')
else:
	print('NO')


n = int(input())
b = [0] * n
a = [0] * n
for i in range(n):
	(a[i], b[i]) = input().split()
l = 0
for i in range(n):
	a[i] = int(a[i])
	if l == 0 and a[i] <= 20000:
		if b[i] == 'South':
			l += a[i]
		else:
			print('NO')
			break
	elif l == 20000 and a[i] <= 20000:
		if b[i] == 'North':
			l -= a[i]
		else:
			print('NO')
			break
	elif b[i] == 'North':
		if l >= a[i]:
			l -= a[i]
		else:
			print('NO')
			break
	elif b[i] == 'South':
		if l + a[i] <= 20000:
			l += a[i]
		else:
			print('NO')
			break
else:
	if l == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
nw = 10000
ans = 'YES'
for i in range(n):
	(d, k) = input().split()
	d = int(d)
	if k == 'East':
		if nw == 10000 or nw == -10000:
			ans = 'NO'
	elif k == 'West':
		if nw == 10000 or nw == -10000:
			ans = 'NO'
	elif k == 'North':
		nw += d
		if nw > 10000:
			ans = 'NO'
	else:
		nw -= d
		if nw < -10000:
			ans = 'NO'
print('YES' if ans == 'YES' and nw == 10000 else 'NO')


total = 0
for _ in range(int(input().strip())):
	(dist, direction) = input().strip().split()
	dist = int(dist)
	if total == 0:
		if direction[0] != 'S':
			print('NO')
			quit()
	if total == 20000:
		if direction[0] != 'N':
			print('NO')
			quit()
	if direction[0] == 'S':
		total += dist
		if total > 20000:
			print('NO')
			quit()
	if direction[0] == 'N':
		total -= dist
		if total < 0:
			print('NO')
			quit()
print(['YES', 'NO'][total != 0])


Q = int(input())
X = 0
for _ in range(Q):
	A = input().strip().split(' ')
	D = int(A[0])
	if X == 0:
		if A[1][0] != 'S':
			print('NO')
			break
		else:
			X += D
			if X > 20000:
				print('NO')
				break
			X %= 40000
			if X > 20000:
				X = 40000 - X
	elif X == 20000:
		if A[1][0] != 'N':
			print('NO')
			break
		else:
			X += D
			if X > 40000:
				print('NO')
				break
			X %= 40000
			if X > 20000:
				X = 40000 - X
	elif A[1][0] == 'S':
		X += D
		if X > 20000:
			print('NO')
			break
		X %= 40000
		if X > 20000:
			X = 40000 - X
	elif A[1][0] == 'N':
		X -= D
		if X < 0:
			print('NO')
			break
		X %= 40000
		if X > 20000:
			X = 40000 - X
else:
	if X == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
n = int(stdin.readline())
flag = False
LIMITE = 20 * 1000
(x, y) = (0, LIMITE)
for i in range(n):
	(d, direc) = stdin.readline().split()
	d = int(d)
	if y == LIMITE and direc != 'South' or (y == 0 and direc != 'North') or y < 0 or (y > LIMITE):
		flag = True
	if direc == 'South':
		y -= d
	elif direc == 'North':
		y += d
	elif direc == 'East':
		x += d
	else:
		x -= d
if y != LIMITE:
	flag = True
if flag:
	print('NO')
else:
	print('YES')


def solve():
	n = int(input())
	y = 20000
	for i in range(n):
		(l, d) = input().split()
		if y == 20000 and d != 'South':
			return False
		if y == 0 and d != 'North':
			return False
		l = int(l)
		if d == 'South':
			y -= l
		elif d == 'North':
			y += l
		if not 0 <= y <= 20000:
			return False
	return y == 20000
print('YES' if solve() else 'NO')


n = int(input())
y = 0
x = 0
for i in range(n):
	s = input()
	k = int(s[:s.find(' ')])
	d = s[s.find(' ') + 1:]
	if d == 'South':
		if y <= 20000 and y + k > 20000 or (y >= 20000 and y - k < 20000):
			print('NO')
			exit(0)
		if y >= 20000:
			y -= k
		else:
			y += k
	if d == 'North':
		if y <= 20000 and y - k < 0 or (y >= 20000 and y + k > 40000):
			print('NO')
			exit(0)
		if y >= 20000:
			y += k
		else:
			y -= k
	y %= 40000
	if (d == 'West' or d == 'East') and (y == 20000 or y == 0):
		print('NO')
		exit(0)
if y == 0:
	print('YES')
else:
	print('NO')


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
c = 0
for _ in range(iinput()):
	(km, dirr) = map(str, input().split())
	km = int(km)
	if dirr == 'North':
		c -= km
	elif dirr == 'South':
		c += km
	elif c == 0 or c == 20000:
		print('NO')
		exit()
	if c < 0 or c > 20000:
		print('NO')
		exit()
if c == 0:
	print('YES')
else:
	print('NO')


import sys

def sol2(n):
	dis = 0
	for i in range(n):
		(x, dir) = input().split()
		x = int(x)
		if dis > 20000 or dis < 0:
			return 'NO'
		if dir[0] == 'N':
			dis -= x
		elif dir[0] == 'S':
			dis += x
		elif dis == 0 or dis == 20000:
			return 'NO'
	return 'YES' if dis == 0 else 'NO'
n = int(input())
print(sol2(n))


n = int(input())
x = 0
fl = True
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if x == 0 and d != 'South' or (x == 20000 and d != 'North'):
		fl = False
		break
	if d == 'South':
		x += t
	elif d == 'North':
		x -= t
	if x < 0 or x > 20000:
		fl = False
		break
if x != 0:
	fl = False
if fl:
	print('YES')
else:
	print('NO')


n = int(input())
Y = 0
for i in range(n):
	temp = input().split()
	(t, dir) = (int(temp[0]), temp[1])
	if Y == 0 and dir != 'South' or (Y == 20000 and dir != 'North') or (not 0 <= Y <= 20000):
		print('NO')
		exit()
	elif dir == 'North':
		Y -= t
	elif dir == 'South':
		Y += t
print('YES') if Y == 0 else print('NO')


n = int(input())
s = 0
for i in range(0, n):
	case = input().split()
	if case[1] == 'South':
		s += int(case[0])
	if case[1] == 'North':
		s -= int(case[0])
	if case[1] == 'South' or case[1] == 'North':
		if int(case[0]) > 20000 or s > 20000 or s < 0:
			s = 1
			break
	if s == 20000 or s == 0:
		if case[1] == 'East' or case[1] == 'West':
			s = 1
			break
if s == 0:
	print('YES')
else:
	print('NO')


coord = 0
n = int(input())
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	if d == 'North':
		coord = coord - t
	elif d == 'South':
		coord = coord + t
	if coord < 0 or coord > 20000:
		print('NO')
		return
	if coord == 0 and (d == 'East' or d == 'West'):
		print('NO')
		return
	if coord == 20000 and (d == 'East' or d == 'West'):
		print('NO')
		return
if coord == 0:
	print('YES')
else:
	print('NO')


n = int(input())
p = 0
r = 0
for j in range(n):
	x = input().split()
	if x[1] == 'North':
		p -= int(x[0])
	if x[1] == 'South':
		p += int(x[0])
	if p < 0 or p > 20000:
		r = 1
	if x[1] == 'East' or x[1] == 'West':
		if p == 0 or p == 20000:
			r = 1
if p != 0:
	r = 1
if r & 1:
	print('NO')
else:
	print('YES')


from sys import *
from math import *
n = int(stdin.readline())
m = []
for i in range(n):
	a = list(stdin.readline().split())
	m.append(a)
x = 0
f = 0
for i in range(n):
	if x == 0 and m[i][1] != 'South':
		f = 1
		break
	if x == 20000 and m[i][1] != 'North':
		f = 1
		break
	if m[i][1] == 'South':
		x += int(m[i][0])
		if x > 20000:
			f = 1
			break
	if m[i][1] == 'North':
		x -= int(m[i][0])
		if x < 0:
			f = 1
			break
if x != 0 or f == 1:
	print('NO')
else:
	print('YES')


m = int(input())
sp = 20000
answer = True
dist = 0
for i in range(m):
	(a, b) = input().split()
	if dist == 0 and b[0] != 'S':
		answer = False
	if dist == sp and b[0] != 'N':
		answer = False
	if b[0] == 'S':
		dist += int(a)
	if b[0] == 'N':
		dist -= int(a)
	if dist > sp or dist < 0:
		answer = False
answer = answer and dist == 0
print('YES' if answer else 'NO')


point = 0
n = int(input())
for i in range(n):
	(length, direction) = input().split()
	length = int(length)
	if point == 0 and direction != 'South':
		print('NO')
		quit()
	if point == 20000 and direction != 'North':
		print('NO')
		quit()
	if direction == 'East' or direction == 'West':
		continue
	if direction == 'South':
		if point + length > 20000:
			print('NO')
			quit()
		else:
			point += length
	if direction == 'North':
		if point - length < 0:
			print('NO')
			quit()
		else:
			point -= length
print('YES' if point == 0 else 'NO')


import sys
n = int(input())
loc = 0
description = list()
for i in range(0, n):
	(t, d) = input().split()
	description.append([int(t), d])
for item in description:
	if loc == 0 and item[1] != 'South':
		print('NO')
		sys.exit()
	elif loc == -20000 and item[1] != 'North':
		print('NO')
		sys.exit()
	if item[1] == 'South':
		if loc - item[0] < -20000:
			print('NO')
			sys.exit()
		else:
			loc -= item[0]
	elif item[1] == 'North':
		if loc + item[0] > 0:
			print('NO')
			sys.exit()
		else:
			loc += item[0]
if loc == 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = 0
y = 0
fl = True
for i in range(n):
	ar = input().split()
	d = int(ar[0])
	if fl:
		if x == 0 and ar[1] != 'South':
			fl = False
		if x == 20000 and ar[1] != 'North':
			fl = False
		if ar[1][0] == 'S':
			if x + d > 20000:
				fl = False
			else:
				x += d
		if ar[1][0] == 'N':
			if x - d < 0:
				fl = False
			else:
				x -= d
		if ar[1][0] == 'E':
			y = (x + d) % 40000
		if ar[1][0] == 'W':
			y = (40000 + x - d) % 40000
if x != 0 or not fl:
	print('NO')
else:
	print('YES')


n = int(input())
bal = 0
MERRY_CHRISTMAS = {'South': 1, 'North': -1, 'West': 0, 'East': 0}
for i in range(n):
	(t, d) = input().split()
	t = int(t)
	bal += MERRY_CHRISTMAS[d] * t
	if bal % 20000 == 0 and d in {'West', 'East'}:
		print('NO')
		exit(0)
	if bal < 0 or bal > 20000:
		print('NO')
		exit(0)
print('YES' if bal == 0 else 'NO')


n = int(input())
x = 0
ans = 'YES'
for i in range(n):
	(a, s) = input().split()
	a = int(a)
	if s == 'South':
		if x + a > 20000 or x == 20000:
			ans = 'NO'
		x += a
	elif s == 'North':
		if x == 0 or x - a < 0:
			ans = 'NO'
		x -= a
	elif x % 20000 == 0:
		ans = 'NO'
if x != 0:
	ans = 'NO'
print(ans)


n = int(input())
reachednorth = True
reachedsouth = False
tosouth = 20000
tonorth = 0
flag = True
for i in range(n):
	a = input().split()
	(m, d) = (int(a[0]), a[1])
	if (reachednorth or reachedsouth) and d in ('East', 'West') and (m != 0):
		flag = False
		break
	elif d in ('East', 'West'):
		pass
	elif d == 'South' and (not reachedsouth):
		if m > tosouth:
			flag = False
			break
		else:
			tosouth -= m
			tonorth += m
		if tosouth == 0:
			reachedsouth = True
		if m > 0:
			reachednorth = False
	elif d == 'South' and reachedsouth:
		flag = False
		break
	elif d == 'North' and reachednorth:
		flag = False
		break
	elif d == 'North' and (not reachednorth):
		if m > tonorth:
			flag = False
			break
		else:
			tonorth -= m
			tosouth += m
		if tonorth == 0:
			reachednorth = True
		if m > 0:
			reachedsouth = False
if flag and reachednorth:
	print('YES')
else:
	print('NO')


import sys

def Main(n):
	y = 0
	for _ in range(n):
		(t, d) = input().split()
		t = int(t)
		if y < 0 or y > 20000:
			print('NO')
			return 0
		if d[0] == 'N':
			y -= t
		elif d[0] == 'S':
			y += t
		elif y == 0 or y == 20000:
			print('NO')
			return 0
	print('YES' if y == 0 else 'NO')
n = int(input())
Main(n)


n = int(input())
a = []
pos = 0
r = 0
for i in range(n):
	x = input().split()
	if x[1] == 'North':
		pos = pos - int(x[0])
	if x[1] == 'South':
		pos = pos + int(x[0])
	if pos < 0 or pos > 20000:
		r = 1
	if x[1] == 'East' or x[1] == 'West':
		if pos == 0 or pos == 20000:
			r = 1
if pos != 0:
	r = 1
if r & 1:
	print('NO')
else:
	print('YES')


def get_m(i):
	lis = i.split(' ')
	return int(lis[0])
n = int(input())
chk = 0
chk2 = 1
sam = 0
direc = []
for i in range(n):
	direc.append(input())
if 'South' in direc[0]:
	chk = 1
for i in direc:
	c = 0
	d = 0
	if 'South' in i:
		c = get_m(i)
	elif 'North' in i:
		d = get_m(i)
	sam = sam - d + c
	if d > 20000 or c > 20000 or 20000 < sam or (sam < 0):
		chk2 = 0
	elif sam == 0 and direc[direc.index(i)] != direc[-1]:
		if 'South' in direc[direc.index(i) + 1]:
			chk2 *= 1
		else:
			chk2 *= 0
	elif sam == 20000 and direc[direc.index(i)] != direc[-1]:
		if 'North' in direc[direc.index(i) + 1]:
			chk2 *= 1
		else:
			chk2 *= 0
if chk == 1 and chk2 == 1 and (sam == 0):
	print('YES')
else:
	print('NO')


n = int(input())
pos = 0
answer = 'YES'
for i in range(n):
	(t, d) = [x for x in input().split()]
	t = int(t)
	if pos == 0:
		if d != 'South':
			answer = 'NO'
		elif t > 20000:
			answer = 'NO'
		else:
			pos = t
	elif pos == 20000:
		if d != 'North':
			answer = 'NO'
		elif t > 20000:
			answer = 'NO'
		else:
			pos = 20000 - t
	elif d == 'South':
		if t > 20000 - pos:
			answer = 'NO'
		else:
			pos += t
	elif d == 'North':
		if t > pos:
			answer = 'NO'
		else:
			pos -= t
if pos == 0 and answer != 'NO':
	print('YES')
else:
	print('NO')


n = int(input())
inst = []
for i in range(0, n):
	inst.append(input())
ok = True
instN = 0
NL = 0
i = 0

def dchar(dirstr):
	if dirstr.find('South') > 0:
		return 'S'
	elif dirstr.find('East') > 0:
		return 'E'
	elif dirstr.find('West') > 0:
		return 'W'
	elif dirstr.find('North') > 0:
		return 'N'

def dnum(dirstr):
	return int(dirstr[:dirstr.find(' ')])
while ok and instN < n:
	if NL == 0 and dchar(inst[instN]) != 'S':
		ok = False
	elif NL == 20000 and dchar(inst[instN]) != 'N':
		ok = False
	if dchar(inst[instN]) == 'S' and ok:
		NL += dnum(inst[instN])
	elif dchar(inst[instN]) == 'N' and ok:
		NL -= dnum(inst[instN])
	if NL > 20000 or NL < 0:
		ok = False
	instN += 1
if NL == 0 and ok:
	print('YES')
else:
	print('NO')


n = int(input())
dist = 0
for move in range(n):
	(d, c) = input().split()
	d = int(d)
	if dist == 0:
		if c != 'South':
			print('NO')
			exit()
	if dist == 20000:
		if c != 'North':
			print('NO')
			exit()
	if c == 'North':
		dist -= d
	elif c == 'South':
		dist += d
	if dist < 0 or dist > 20000:
		print('NO')
		exit()
if dist == 0:
	print('YES')
else:
	print('NO')


s = 'YES'
n = int(input())
dis = 0
for i in range(n):
	(t, dir) = map(str, input().split())
	t = int(t)
	if dis == 0 and dir != 'South' or (dis == 20000 and dir != 'North'):
		s = 'NO'
		break
	if dir == 'North':
		if dis - t < 0:
			s = 'NO'
			break
	elif dir == 'South':
		if dis + t > 20000:
			s = 'NO'
			break
	if dir in ['North', 'South']:
		dis += -t if dir == 'North' else t
print(s if dis == 0 else 'NO')


n = int(input())
d = 0
ans = 'YES'
for i in range(n):
	(x, y) = input().split()
	x = int(x)
	if d == 0 and y != 'South':
		ans = 'NO'
		break
	if d == 20000 and y != 'North':
		ans = 'NO'
		break
	if y == 'North':
		if d < x:
			ans = 'NO'
			break
		else:
			d -= x
	if y == 'South':
		if d + x > 20000:
			ans = 'NO'
			break
		else:
			d = d + x
if d != 0:
	ans = 'NO'
print(ans)


def bla():
	n = int(input())
	l = []
	for i in range(n):
		tuppl = tuple(input().split())
		l.append(tuppl)
	position = -10000
	for i in range(len(l)):
		km = int(l[i][0])
		direction = l[i][1]
		if position == -10000:
			if direction in ['West', 'East', 'North']:
				print('NO')
				return
		elif position == 10000:
			if direction in ['West', 'East', 'South']:
				print('NO')
				return
		if direction == 'South':
			position += km
			if position > 10000:
				print('NO')
				return
		elif direction == 'North':
			position -= km
			if position < -10000:
				print('NO')
				return
	if position == -10000:
		print('Yes')
	else:
		print('No')
bla()


n = int(input())
p = 10000
for i in range(n):
	(x, d) = input().split()
	x = int(x)
	if d == 'South':
		if p != -10000 and p - x >= -10000:
			p -= x
		else:
			print('NO')
			exit()
	elif d == 'North':
		if p != 10000 and p + x <= 10000:
			p += x
		else:
			print('NO')
			exit()
	elif p == 10000 or p == -10000:
		print('NO')
		exit()
if p == 10000:
	print('YES')
else:
	print('NO')


n = int(input())
pos = 0
is_correct = True
for i in range(n):
	(d, direc) = input().split()
	d = int(d)
	if is_correct:
		if pos == 0 and direc != 'South':
			is_correct = False
		if pos == 20000 and direc != 'North':
			is_correct = False
		if direc in ('North', 'South'):
			if direc == 'North':
				pos -= d
			elif direc == 'South':
				pos += d
			if pos < 0 or pos > 20000:
				is_correct = False
is_correct = is_correct and pos == 0
if is_correct:
	print('YES')
else:
	print('NO')


from sys import exit
pos = 0
for i in range(int(input())):
	(t, d) = input().split()
	t = int(t)
	if pos == 0 and d[0] != 'S' or (pos == 20000 and d[0] != 'N'):
		print('NO')
		exit()
	elif d[0] == 'S':
		pos += t
	elif d[0] == 'N':
		pos -= t
	if pos < 0 or pos > 20000:
		print('NO')
		exit()
if pos == 0:
	print('YES')
else:
	print('NO')


def main():
	from sys import stdin, stdout
	d = 0
	flag = True
	n = int(stdin.readline())
	for i in range(n):
		(a, b) = stdin.readline().strip().split()
		if d < 0 or d > 20000:
			flag = False
		if d == 0:
			if b != 'South':
				flag = False
		if d == 20000:
			if b != 'North':
				flag = False
		if b == 'South':
			d += int(a)
		if b == 'North':
			d -= int(a)
	if flag:
		if d:
			stdout.write('NO')
		else:
			stdout.write('YES')
	else:
		stdout.write('NO')
main()


from math import sin, pi
n = int(input())
(X, Y) = (0, 0)
for i in range(n):
	temp = input().split()
	(t, dir) = (int(temp[0]), temp[1])
	if Y == 0 and dir != 'South' or (Y == 20000 and dir != 'North') or (not 0 <= Y <= 20000):
		print('NO')
		exit()
	elif dir == 'North':
		Y -= t
	elif dir == 'South':
		Y += t
	elif dir == 'West':
		X = (X - t / sin(Y * pi / 40000)) % 20000
	elif dir == 'East':
		X = (X + t / sin(Y * pi / 40000)) % 20000
print('YES') if Y == 0 else print('NO')


N = int(input())
cur_point = 0
limit_down = -20000
limit_up = 0
for index in range(N):
	(value, dest) = input().split()
	value = int(value)
	if dest[0] == 'S':
		if cur_point <= limit_down:
			print('NO')
			exit(0)
		if cur_point - value < limit_down:
			print('NO')
			exit(0)
		cur_point -= value
	elif dest[0] == 'N':
		if cur_point >= limit_up:
			print('NO')
			exit(0)
		if cur_point + value > limit_up:
			print('NO')
			exit(0)
		cur_point += value
	elif cur_point == limit_down or cur_point == limit_up:
		print('NO')
		exit(0)
if cur_point == limit_up:
	print('YES')
else:
	print('NO')


import sys
import math
import bisect

def solve(A):
	upper = 10 * 10 ** 3
	pos = 10 * 10 ** 3
	for p in A:
		if p[1] == 'North':
			pos += p[0]
		elif p[1] == 'South':
			pos -= p[0]
		elif p[1] == 'East':
			if abs(pos) == upper:
				return False
		elif p[1] == 'West':
			if abs(pos) == upper:
				return False
		if pos > upper or pos < -upper:
			return False
	return pos == upper

def main():
	A = []
	for _ in range(int(input())):
		s = input().split()
		A.append([int(s[0]), s[1]])
	if solve(A):
		print('YES')
	else:
		print('NO')
main()


from collections import defaultdict
import sys, os, math
n = int(input())
temp = 0
ans = 'YES'
for i in range(n):
	(a, s) = input().split()
	if temp == 0 and s != 'South' or (temp == 20000 and s != 'North'):
		ans = 'NO'
	if s == 'North':
		temp -= int(a)
	if s == 'South':
		temp += int(a)
	if temp < 0 or temp > 20000:
		ans = 'NO'
if temp == 0 and ans == 'YES':
	print('YES')
else:
	print('NO')


n = int(input())
steps = []
for i in range(n):
	(a, b) = input().split(' ')
	steps.append((a, b))
north = True
south = False
distance = 0
result = 'YES'
for i in steps:
	if north:
		if i[1] != 'South':
			result = 'NO'
			break
	elif south:
		if i[1] != 'North':
			result = 'NO'
			break
	if i[1] == 'South':
		distance += int(i[0])
		if distance > 20000:
			result = 'NO'
			break
	elif i[1] == 'North':
		distance -= int(i[0])
		if distance < 0:
			result = 'NO'
			break
	if distance == 0:
		north = True
		south = False
	elif distance == 20000:
		south = True
		north = False
	else:
		north = False
		south = False
if result == 'NO':
	print(result)
elif distance != 0:
	print('NO')
else:
	print('YES')


n = input()
flag = True
now = [0, 0]
for i in range(int(n)):
	(step, way) = input().split()
	if now[0] == 0 and way != 'South':
		flag = False
		break
	if now[0] == 20000 and way != 'North':
		flag = False
		break
	if way == 'South':
		now[0] += int(step)
	elif way == 'North':
		now[0] -= int(step)
	elif way == 'West':
		now[1] += int(step)
	elif way == 'East':
		now[1] -= int(step)
	if now[0] > 20000 or now[0] < 0:
		flag = False
		break
if flag and now[0] == 0:
	print('YES')
else:
	print('NO')


n = int(input())
cur = 0
for i in range(n):
	(dist, typ) = input().split()
	dist = int(dist)
	if typ in ['West', 'East']:
		if cur in [0, 20000]:
			print('NO')
			break
		continue
	if typ == 'North':
		if cur < dist:
			print('NO')
			break
		cur -= dist
	elif typ == 'South':
		if 20000 - cur < dist:
			print('NO')
			break
		cur += dist
else:
	if cur != 0:
		print('NO')
	else:
		print('YES')


n = int(input())
moves = []
for i in range(n):
	(t, d) = input().split()
	moves.append((int(t), d))
p = 0
ans = True
for i in range(n):
	(t, d) = moves[i]
	if p == 0 and d != 'South':
		ans = False
		break
	if p == 20000 and d != 'North':
		ans = False
		break
	if d == 'South':
		if p + t > 20000:
			ans = False
			break
		else:
			p += t
	elif d == 'North':
		if p - t < 0:
			ans = False
			break
		else:
			p -= t
if ans and p == 0:
	print('YES')
else:
	print('NO')


N = int(input())
current = 0
answer = 'YES'
half_circ = 20000
for n in range(N):
	(step, direction) = [j for j in input().split()]
	step = int(step)
	if current == 0:
		if direction == 'South' and step <= half_circ:
			current += step
		else:
			answer = 'NO'
			break
	elif current == half_circ:
		if direction == 'North' and step <= half_circ:
			current -= step
		else:
			answer = 'NO'
			break
	else:
		if direction == 'North':
			current -= int(step)
		elif direction == 'South':
			current += int(step)
		if current < 0 or current > 20000:
			answer = 'NO'
			break
if current != 0:
	answer = 'NO'
print(answer)


t = int(input())
cur = 0
for i in range(t):
	(dist, di) = input().split()
	dist = int(dist)
	if cur == 0 and di != 'South':
		print('NO')
		exit(0)
	elif cur == 20000 and di != 'North':
		print('NO')
		exit(0)
	if di == 'South':
		cur += dist
	elif di == 'North':
		cur -= dist
	if not 0 <= cur <= 20000:
		print('NO')
		exit(0)
if cur == 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = 0
for i in range(n):
	(change, way) = input().split()
	if x == 0 and way != 'South':
		print('NO')
		exit()
	elif x == 20000 and way != 'North':
		print('NO')
		exit()
	if way == 'South':
		x += int(change)
		if x > 20000:
			print('NO')
			exit()
	if way == 'North':
		x -= int(change)
		if x < 0:
			print('NO')
			exit()
if x == 0:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
n = int(input().strip())
dl = []
dn = []
ANP = True
ASP = False
diFN = 0
valid = True
invN = ['North', 'East', 'West']
invS = ['South', 'East', 'West']
for i in range(n):
	direction = input().strip().split()
	dl.append(direction[1])
	dn.append(int(direction[0]))
for i in range(n):
	if valid == False:
		print(i)
	if dl[i] in invN and ANP:
		valid = False
		break
	elif dl[i] in invS and ASP:
		valid = False
		break
	else:
		if dl[i] == 'South':
			diFN += dn[i]
			ANP = False
			if diFN > 20000:
				valid = False
				break
			if diFN == 20000:
				ASP = True
		if dl[i] == 'North':
			ASP = False
			diFN -= dn[i]
			if diFN < 0:
				valid = False
				break
			if diFN == 0:
				ANP = True
if diFN != 0:
	valid = False
if valid:
	print('YES')
else:
	print('NO')


n = int(input())
cur = 0
w = 0
for i in range(n):
	a = input().split()
	num = int(a[0])
	s = a[1]
	if cur == 0 and s != 'South':
		print('NO')
		exit()
	if cur == 20000 and s != 'North':
		print('NO')
		exit()
	if s == 'North':
		cur -= num
		if cur < 0:
			print('NO')
			exit()
	if s == 'South':
		cur += num
		if cur > 20000:
			print('NO')
			exit()
if cur == 0:
	print('YES')
else:
	print('NO')


n = int(input())
dy = {'North': -1, 'South': 1, 'West': 0, 'East': 0}
y = 0
good = True
for _ in range(n):
	(l, w) = input().split()
	y += dy[w] * int(l)
	if y < 0 or y > 20000:
		good = False
		break
	if dy[w] == 0 and (y == 0 or y == 20000):
		good = False
		break
print(['NO', 'YES'][good and y == 0])


from math import sin, pi
n = int(input())
latitude = 10000
bool = True
for _ in range(n):
	(kilometres, direction) = input().split(' ')
	kilometres = int(kilometres)
	if bool:
		if latitude == 10000 and direction not in ['South', 'S'] or (latitude == -10000 and direction not in ['North', 'N']):
			bool = False
		else:
			if direction in ['North', 'N']:
				latitude += kilometres
			elif direction in ['South', 'S']:
				latitude += -kilometres
			if abs(latitude) > 10000:
				bool = False
if latitude != 10000:
	bool = False
if bool:
	print('YES')
else:
	print('NO')


i = int(input())
a = []
for z in range(i):
	x = input()
	x = x.split(' ')
	x[0] = int(x[0])
	a.insert(z, x)
q = 'YES'
c = 0
for z in range(i):
	if a[z][1] != 'South' and c == 0:
		q = 'NO'
	if a[z][1] != 'North' and c == 20000:
		q = 'NO'
	if a[z][1] == 'South':
		c += a[z][0]
	if a[z][1] == 'North':
		c -= a[z][0]
	if c > 20000 or c < 0:
		q = 'NO'
if c != 0:
	q = 'NO'
print(q)