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: interview

Starter code:

Solutions:
"""
Codeforces Good Bye 2016 Contest Problem B

Author  : chaotic_iak
Language: Python 3.5.2
"""

################################################### SOLUTION

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"

#################################################### HELPERS

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())


#!/usr/bin/env python3

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())

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())
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])

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')

 
def __starting_point():
    main()

__starting_point()

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())
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")


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])
    else:
        if 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())

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())
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")


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
    else:
        if 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
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
    else:
        if dir=='North':
            currentPos-=k
        elif dir=='South':
            currentPos+=k
    #print(currentPos)
if currentPos!=0:
    b=1
if b==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
    else:
        if (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")

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

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())
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')
    
    


'''
Created on 30 dec. 2016

@author: Moldovan
'''
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())
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")


#!/usr/bin/env python3


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
        else:
            if 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()

# -*- coding: utf-8 -*-
# @Author: q7199
# @Date:   2016-12-30 22:25:59
# @Last Modified by:   q7199
# @Last Modified time: 2016-12-30 22:30:38

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:
        #print("NO")
        flag = False
        break
if flag and now[0] == 0:
    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")


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')

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")