Harryxun/stf_run huggingface dataset:
N = int(input())
S = input()

for i in range(N-1):
  if i == 0:
    count = 1
  else:
    if S[i] != S[i+1]:
      count += 1
    else:
      continue
print(count)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0

for i in range(N-1):
  if S[i] != S[i+1]:
    ans += 1
ans += 1
print(ans)
from collections import deque

import numpy as np
import sys
#input = sys.stdin.readline

sys.setrecursionlimit(5000)

def get_adj_tiles(v):
    i, j = v
    res = [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]
    return res

def bfs(point, field, target):
    visited = []
    que = deque()
    que.append((point, 1))
    
    while True:
        v, depth = que.popleft()
        visited.append(v)
        adjs = get_adj_tiles(v)
        for a in adjs:
            if field[a[0]][a[1]] == '.' and a not in visited:
                if a == target:
                    return depth + 1
                else:
                    que.append((a, depth+1))
        if len(que) == 0:
            return 0

def main():
    H, W = list(map(int, input().split()))
    target = (H, W)
    field = [['#'] * (W + 2) for _ in range(H + 2)]
    for i in range(H):
        values = list(input())
        field[i+1][1:-1] = values

    number_of_whites = 0
    for i in range(H+2):
        for j in range(W+2):
            if field[i][j] == '.':
                number_of_whites += 1
    shortest_path = bfs((1, 1), field, target)
    if shortest_path > 0:
        print(number_of_whites - shortest_path)
    else:
        print(-1)
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

H, W = list(map(int, input().split()))
M = [[-1]*(W+2)]
ans = 0
for _ in range(H):
    s = input()
    ans += s.count('.')
    M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])
M += [[-1]*(W+2)]

queue = [(1,1)]
M[1][1] = 1
dr = [(+1,0),(-1,0),(0,+1),(0,-1)]
turn = 1
while len(queue)>0:
    turn += 1
    queue_new = []
    for qx, qy in queue:
        for dx, dy in dr:
            x, y = qx+dx, qy+dy
            if M[y][x]==0:
                M[y][x] = turn
                queue_new.append((x,y))
    queue = queue_new

print(ans-M[H][W] if M[H][W]>0 else -1)
S=input()
if s="AAA" or s="BBB":
  print("No")
else:print("Yes")


### FIXED CODE ###

S=input()
if S=="AAA" or S=="BBB":
  print("No")
else:print("Yes")
import sys
sys.setrecursionlimit(4000)

def dfs(now):
  v[now]=0
  for i in edge[now]:
    if v[i]:
      point[i]+=point[now]
      dfs(i)

n,q=map(int,input().split())
edge=[[] for _ in range(n)]
point=[0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
for i in range(q):
  p,x=map(int,input().split())
  point[p-1]+=x
v=[1]*n
dfs(0)
print(*point)

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000)
n,q=map(int,input().split())
e=[[] for _ in range(n)]
cnt=[0]*n
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a-1].append(b-1)
  e[b-1].append(a-1)
for _ in range(q):
  x,y=map(int,input().split())
  cnt[x-1]+=y
vis=[1]*n
queue=[0]
vis[0]=0
while queue:
  now=queue.pop()
  for i in e[now]:
    if vis[i]:
      queue.append(i)
      cnt[i]+=cnt[now]
      vis[i]=0
print(' '.join(map(str,cnt)))
n=int(input())
a=list(map(int,input().split()))
m=0
def yakusu(x):
  lst=[]
  for i in range(1,x**(0.5)+1):
    if x%i==0:
      lst.append(i)
      lst.append(x//i)
  return list(set(lst))    
for i in range(n):
  for j in range(len(yakusu(a[i]))):
    while (yakusu(a[i]))[j]%2==0:
      (yakusu(a[i]))[j]==(yakusu(a[i]))[j]//2
      m+=1
print(m)

  


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=0
for i in range(n):
  while a[i]%2==0:
    a[i]=a[i]//2
    m+=1
print(m)
import itertools
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def tyou(n, r):
    return combinations_count(n + r - 1, r)


N,K=list(map(int,input().split()))
aka=N-K
for i in range(1,k+1):
    if(K-i>=0 and aka-(i-1)>=0):
        p=tyou(i,K-i)*tyou(i+1,aka-(i-1))
        ans=p%(10**9+7)
        print(ans)

### FIXED CODE ###

def comb(n, r):
    if n == 0 or r == 0:
        return 1
    if n < r:
        return 0
    a = b = 1
    r = min(n-r, r)
    for i in range(n-r+1,n+1):
        a*=i
    for i in range(1,r+1):
        b*=i
    
    return a//b
 
N, K = map(int, input().split())
MOD = int(1e9)+7
 
for i in range(1, K+1):
    temp = comb(N-K+1, i) * comb(K-1, i-1)
    print(int(temp % MOD))
if __name__=='__main__':
    N = int(input())
        #pc, pr = map(int, input().split())
        #N = list(map(int,input().split()))
	print("Yes" if N%9 ==0 else "No")

### FIXED CODE ###

if __name__=='__main__':
    N = int(input())
    print("Yes" if N%9 ==0 else "No")
s=list(input())
k=int(input())

def toA(char):
    return (ord('z')-ord(char)+1)%26


def toC(char,k):
    if(ord('z')-ord(char)>=k):
        return chr(ord(char)+k)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))


for i in range(len(s)):
    if(k==0):
        break
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= toC(s[i],k)
print("".join(s))


### FIXED CODE ###

s=list(input())
k=int(input())

def toA(char):
    return (ord('z')-ord(char)+1)%26

def toC(char,k):
    if(ord('z')-ord(char)>=k%26):
        return chr(ord(char)+k%26)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))
for i in range(len(s)):
    if(k==0):
        break
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= toC(s[i],k)
print("".join(s))
n,a,b=map(int,input().split())
c=0
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		c=n//(a+b)
		d=a*c+n-c*(a+b)
		print(d)
	else:
		if n>=a:
			c=n//a
			ptint(a*c)
		else:
			print(n)

### FIXED CODE ###

n,a,b=map(int,input().split())
c=n//(a+b)
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		if n-c*(a+b)<=a:
			d=a*c+n-c*(a+b)
			print(d)
		else:
			d=a*(c+1)
			print(d)
	else:
		if n>=a:
			print(a)
		else:
			print(n)
n = int(input())
for i in range(7) :
    if (2**i) < n :
        ans = 2**i
print(ans)


### FIXED CODE ###

N = int(input())

nList = [i + 1 for i in range(N)]
res = -1
counter = -1
for n in nList :
    count = 0
    buf = n
    while buf % 2 == 0 :
        count += 1
        buf = buf / 2
    if counter < count :
        counter  = count
        res = n
print(res)
import numpy as np
n = int(input()) 
#n=4
lst = [int(i) for i in input().split()]
#lst = [2, 2, 8, 40]
#lst = [5, 13, 8, 1000000000]
#lst = [0, 1, 0]
hps = np.array(lst)
while(1):
    hps = sorted(hps)
    #print(hps)
    if(hps[0]==0): break
    if(hps[0]==hps[len(hps)-1]): break
    hps[1] = hps[1] - hps[0]
print(hps[1])

### FIXED CODE ###

a, b= (int(i) for i in input().split())  

if(b%a==0):
    print(a+b)
else:
    print(b-a)
x,y,z=map(int,input().split()):
print(z,x,y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(str(z)+" "+str(x)+" "+str(y))
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

### FIXED CODE ###

N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)
#!/usr/bin/env python3
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)

### FIXED CODE ###

class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], mod - 2, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)
N = int(input())
if (N // 1.08) == ((N+1) //1.08) or int(n * 1.08) != N and N!=int( (n+1) * 1.08):
    print(':(')
else:
    print((N//1.08))

### FIXED CODE ###

N = int(input())
n = int(N/1.08)
if (int(n * 1.08) < N and N < int((n+1) * 1.08)):
    print(':(')
else:
    print(int(N//1.08)+1)
from sys import stdin
from itertools import product

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
 
else:
    print(zantei)

### FIXED CODE ###

from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)
N = int(input())
ls = []
flag = True
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if char in ls:
      flag = False
    else:
      ls.append(char)
if flag == True:
  print('Yes')


### FIXED CODE ###

a, b = map(int, input().split())
for c in range(1, 4):
  if a*b*c % 2 == 1:
    print('Yes')
    break
  else:
    if c == 3:
      print('No')
val = input().split(' ')
x = int(val[0])
y = int(val[1])
a = int(val[2])
b = int(val[3])
c = int(val[4])

p_list = sorted([int(a) for a in input().split(' ')]).reverse()
q_list = sorted([int(a) for a in input().split(' ')]).reverse()
r_list = sorted([int(a) for a in input().split(' ')]).reverse()

xapples = p_list[0:x+1]
yapples = q_list[0:y+1]
zapples = r_list[0:x+y+1]

apples = sorted(xapples.extend(yapples).extend(zapples)).reverse()[0:x+y+1]
print(sum(apples))


### FIXED CODE ###

val = input().split(' ')
x = int(val[0])
y = int(val[1])
a = int(val[2])
b = int(val[3])
c = int(val[4])
 
p_list = sorted([int(a) for a in input().split(' ')])
q_list = sorted([int(a) for a in input().split(' ')])
r_list = sorted([int(a) for a in input().split(' ')])
p_list.reverse()
q_list.reverse()
r_list.reverse()
 
xapples = p_list[0:x]
yapples = q_list[0:y]
zapples = r_list[0:x+y]
 
xapples.extend(yapples)
xapples.extend(zapples)
tmp_apples = sorted(xapples)
tmp_apples.reverse()
apples = tmp_apples[0:x+y]
print(sum(apples))
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - (prev_index + 1)
        break
        print(count)
    else:
        count += a.index(i) - prev_index -1
        two_ago_index = prev_index
        prev_index = a.index(i)
        for j in range(two_ago_index,prev_index+1):
            a[j] = 0

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
count = 1
brick = 0
for i in range(N):
    if a[i] != count:
        brick += 1
    else:
        count += 1
if brick == N:
    print(-1)
else:
    print(brick)
S = input()
T = input()
ansCnt = 0
for i in range(len(S)):
    for j in range(1, len(S) + 1):
        if S[-j] == T[-j]:
            continue
        elif j != len(S):
            S = S[-j] + S[0: -j] + S[-j + 1:]
            ansCnt += 1

if S == T:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()
T = input()
ansCnt = 0
for i in range(len(S)):
    if S == T:
        break
    S = S[-1] + S[0:-1]
if S == T:
    print('Yes')
else:
    print('No')
v=pow(10,9)+7
arr=[]
inp = list(map(int,input().split()))
row=inp[0]
col=in[1]
for i in range(row):
  s=input()
  arr.append(s)
ans=[[0 for i in range(col)]for j in range(row)]
for i in range(col):
  if arr[0][i]=='#':
    break
  else:
    ans[0][i]=1
for i in range(row):
  if arr[i][0]=='#':
    break
  else:
    ans[i][0]=1
for i in range(1,row):
  for j in range(1,col):
    if arr[i][j]=='#':
      continue
    else:
      arr[i][j]=(arr[i-1][j]+arr[i][j-1])%v
print (arr[-1][-1])

### FIXED CODE ###

v=pow(10,9)+7
arr=[]
inp = list(map(int,input().split()))
row=inp[0]
col=inp[1]
for i in range(row):
    s=input()
    arr.append(s)
ans=[[0 for i in range(col)]for j in range(row)]
for i in range(col):
    if arr[0][i]=='#':
        break
    else:
        ans[0][i]=1
for i in range(row):
    if arr[i][0]=='#':
        break
    else:
        ans[i][0]=1
for i in range(1,row):
    for j in range(1,col):
        if arr[i][j]=='#':
            continue
        else:
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%v
print (ans[-1][-1])
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,int((n**0.5))+1):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
        

        

### FIXED CODE ###

a,b=map(str,input().split())
print(b+a)
n,m=map(int,input().split())
ans=0
n%=m
ans=(min(n,(k-n))
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
ans=0
n%=m
#print(n,m)
ans=min(n,(m-n))
print(ans)
N = input()
a = list(map(input().split(N+1))
i = 0
for x in a:
	if x%2!=0 and a[x]%2!=0:
    	i+==1
     
    print(i)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
i=0
for x,y in enumerate (a):
    b=x+1
    if b%2!=0 and y%2!=0:
        i+=1
print(i)
ais = sorted(map(int, raw_input()))
print 'Yes' if sum(ais[:2]) == ais[2] else 'No'

### FIXED CODE ###

ais = sorted(map(int, raw_input().split()))
print 'Yes' if sum(ais[:2]) == ais[2] else 'No'
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
V = []
W = []
for _ in range(n):
    v, w = LI()
    V.append(v)
    W.append(w)

q = I()
vl = []
maxL = 0
for _ in range(q):
    v, l = LI()
    maxL = max(maxL, l)
    vl.append([v,l])

m = min(n, 1 << 10)
dp = [[0]*(maxL + 1) for _ in range(m + 1)]

for i in range(1, m+1):
    v, w = V[i-1], W[i-1]
    for j in range(maxL+1):
        if j < w:
            dp[i][j] = dp[i>>1][j]
        else:
            dp[i][j] = max(dp[i>>1][j], dp[i>>1][j - w] + v)


for i in range(q):
    v, L = vl[i]
    if v <= m:
        print(dp[v][L])
        continue
    cnt = 0
    tmp = v
    v_ = []
    w_ = []
    while tmp > m:
        v_.append(v[tmp-1])
        w_.append(w[tmp-1])
        tmp >>= 1
        cnt += 1
    ret = 0
    for j in range(1 << cnt):
        weight_sum = 0
        value_sum = 0
        idx = j
        for v, w in zip(v_, w_):
            if idx & 1:
                weight_sum += w
                value_sum += v
                if weight_sum > L:
                    break
            idx >>= 1
        else:
            value_sum += dp[tmp][L - weight_sum]
            ret = max(ret, value_sum)
    print(ret)


### FIXED CODE ###

#!/usr/bin/env python3

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

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()
N = int(input())
A = input().split()
for i in range(N):
  count = 0
  for j in range(N-1):
    if i+1 == int(A[j]):
      count += 1
  print(count)


### FIXED CODE ###

import math
R = int(input())
pi = math.pi
print(2*R*pi)
x, y = map(int, input().split())
c = [0]*205
c[1], c[2], c[3] = 3, 2, 1
reword = c[x]+c[y]
if x+y == 2:
    reword += 4

print(reword*100000)


### FIXED CODE ###

x, y = map(int, input().split())
c = [0]*210
c[1], c[2], c[3] = 3, 2, 1
reword = c[x]+c[y]
if x+y == 2:
    reword += 4

print(reword*100000)
import sys
input = sys.stdin.readline
from math import factorial as fact

MOD = 10 ** 9 + 7


def inv(x):
    return pow(x, MOD - 2, MOD)


def comb(n, r):
    return (fact(n) * inv(fact(n - r)) * inv(fact(r))) % MOD




def main():
    X, Y = [int(x) for x in input().split()]

    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    print(x, y)
    if X == x * 2 + y and Y == x + 2 * y:
        a = comb(x + y, x)
        print(a % MOD)
    else:
        print(0)









if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline

def modPow(a, x, p):
    res = 1
    while x > 0:
        if x % 2 != 0:
            res = res * a % p
        a = a * a % p
        x = x // 2
    return res

def modInverse(a, p):
    return modPow(a, p - 2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    X, Y = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7
    y = (X - 2 * Y) // (-3)
    x = (X - y) // 2

    if y < 0 or x < 0:
        print(0)
        exit()
    if X == x * 2 + y and Y == x + 2 * y:
        print(modBinomial(x + y, x, MOD))
    else:
        print(0)









if __name__ == '__main__':
    main()
a,b,c,d = map(int,input().split())
for v in range(100):
    if a - v*d < 0:
        ans = "No"
        break
    if c - v*b < 0:
        ans = "Yes"
        break
print(ans)


### FIXED CODE ###

a,b,c,d = map(int,input().split())
for v in range(1000):
    if c - v*b <= 0:
        ans = "Yes"
        break
    if a - v*d <= 0:
        ans = "No"
        break
print(ans)
import sys
sys.setrecursionlimit(10**5)

N, Q = map(int,input().split())
G = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for _ in range(Q):
    p, x = map(int,input().split())
    counter[p-1] += x

seen = [False]*N

def dfs(v, seen, G, counter):
    seen[v] = True
    for u in G[v]:
        if not seen[u]:
            counter[u] += counter[v]
            dfs(u, seen, G, counter)

dfs(0, seen, G, counter)

for c in counter:
    print(c, end = " ")
print("")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

N, Q = map(int,input().split())
G = [[] for _ in range(N)]
counter = [0] * N

for _ in range(N-1):
    a, b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for _ in range(Q):
    p, x = map(int,input().split())
    counter[p-1] += x

stack, seen = [0], [False]*N
while stack:
    v = stack.pop()
    seen[v] = True

    for u in G[v]:
        if not seen[u]:
            stack.append(u)
            counter[u] += counter[v]

for c in counter:
    print(c, end = " ")
print("")
import sys
h,w=map(int,input().split())
dr=[input()+'.' for _ in range(h)]
dr.append('.'*h)

if h==1 and w==1:
  print('Yes')
  sys.exit()

if dr[0][0]=='#':
  if dr[1][0]!='#' and dr[0][1]!='#':
    print('No')
    sys.exit()
for j in range(1,w-1):
  if dr[0][j]=='#':
    if dr[0][j+1]!='#' and dr[1][j]!='#' and dr[0][j-1]!='#':
      print('No')
      sys.exit()
if dr[0][w-1]=='#':
  if dr[1][w-1]!='#' and dr[0][w-2]!='#':
    print('No')
    sys.exit()
for i in range(1,h-2):
  if dr[i][0]=='#':
    if dr[i+1][0]!='#' and dr[i][1]!='#' and dr[i-1][0]!='#':
      print('No')
      sys.exit()
  for i in range(1,w-1):
    if dr[i][j]=='#':
      if dr[i][j+1]!='#' and dr[i+1][j]!='#' and dr[i-1][j]!='#' and dr[i][j-1]!='#':
        print('No')
        sys.exit()
  if dr[i][w-1]=='#':
    if dr[i+1][w-1]!='#' and dr[i-1][w-1]!='#' and dr[i][w-2]!='#':
      print('N0')
      sys.exit()
if dr[h-1][0]=='#':
  if dr[h-1][1]!='#' and dr[h-2][0]!='#':
    print('N0')
    sys.exit()
for j in range(1,w-1):
  if dr[h-1][j]=='#':
    if dr[h-1][j+1]!='#' and dr[h-1][j-1]!='#' and dr[h-2][j]!='#':
      print('No')
      sys.exit()
if dr[h-1][w-1]=='#':
  if dr[h-1][w-2]!='#' and dr[h-2][w-1]!='#':
    print('N0')
    sys.exit()
print('Yes')

### FIXED CODE ###

h,w=map(int,input().split())
a=['.'*(w+2)]+['.'+input()+'.' for _ in range(h)]+['.'*(w+2)]
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      if not(a[i+1][j]=='#' or a[i-1][j]=='#' or a[i][j+1]=='#' or a[i][j-1]=='#'):
        print('No')
        exit()
print('Yes')
import math

a,b,c,d = map(int,input().split())
cd = math.gcd(c, d)
lcmcd = c*d//cd
ans = 0
for i in range(a,b+1):
  if i % lcmcd != 0:
    ans += 1
print(ans)






### FIXED CODE ###

A,B,C,D = map(int,input().split())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

def F(N,C,D):
  x = N
  x -= N//C
  x -= N//D
  lcm = C*D//gcd(C,D)
  x += N//lcm
  return x

answer = F(B,C,D) - F(A-1,C,D)
print(answer)
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  new_cube = []
  for i in xrange(count):
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
    new_cube = []

### FIXED CODE ###

while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans