Harryxun/stf_run huggingface dataset:
import pdb
a,b,c = map(int, raw_input().strip().split(' '))
if a==b==c:
    if a%2==0:
        print '-1'
    else
        print '0'
elif a%2!=0 or b%2!=0 or c%2!=0:
    print '0'
else:
    Flag = True
    cnt = 0
    for i in range(100000):
        tmp1,tmp2=a,b
        a = b/2+c/2
        b = tmp1/2+c/2
        c = tmp1/2+tmp2/2
        cnt += 1
#         pdb.set_trace()
        if a%2!=0 or b%2!=0 or c%2!=0:
            Flag = False
            break
    if Flag:
        print '-1'
    else:
        print cnt
            


### FIXED CODE ###

import pdb
a,b,c = map(int, raw_input().strip().split(' '))
if a==b==c:
    if a%2==0:
        print -1
    else:
        print 0
elif a%2!=0 or b%2!=0 or c%2!=0:
    print 0
else:
    Flag = True
    cnt = 0
    for i in range(100000):
        tmp1,tmp2=a,b
        a = b/2+c/2
        b = tmp1/2+c/2
        c = tmp1/2+tmp2/2
        cnt += 1
#         pdb.set_trace()
        if a%2!=0 or b%2!=0 or c%2!=0:
            Flag = False
            break
    if Flag:
        print -1
    else:
        print cnt
w = input()                
l = list(w)                
l.sort()                   
ans = "Yes"                
for i in range(len(l)/2):    
    if l[2*i] != l[2*i+1]: 
        ans = "No"         
        break              
print(ans)                 
                           
                           


### FIXED CODE ###

w = input()                    
l = list(w)                    
l.sort()                       
ans = "Yes"                    
if len(l)%2 != 0:
    print("No")
    exit()
for i in range(int(len(l)/2)): 
    if l[2*i] != l[2*i+1]:     
        ans = "No"             
        break                  
print(ans)
X=int(input())
Y=int(input())
Z=int(input())
print(Z, X, Y)

### FIXED CODE ###

X,Y,Z=input().split()
print(Z,X,Y)
from collections import counter as C
print(9)

### FIXED CODE ###

from collections import Counter as C
N = int(input())
A = [int(a) for a in input().split()]
X = C(A)
ans = 0
for x in X:
    ans += X[x] if X[x] < x else X[x] - x
print(ans)
n = int(input())
if n == "SAT":
    print(1)
elif n == "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n == "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(7)

### FIXED CODE ###

n = input()
if n == "SAT":
    print(1)
elif n == "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n == "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(7)
n = int(input())


def ts(x):
    return x * (x + 1)


m = n
for i in range(math.ceil(math.sqrt(2 * n) - 2), math.floor(math.sqrt(2 * n)) + 1, 1):
    if ts(i) < 2 * n <= ts(i + 1):
        m = i + 1
        break

a = n % (m + 1)
b = n // (m + 1)

if m % 2 == 0:
    if a != 0:
        print(a)
    i = 1
    c = 0
    while c != b:
        if i != a and m + 1 - i != a:
            print(i)
            print(m + 1 - i)
            c += 1
        i += 1
else:
    """
  check=[]
  if a!=0:
      check.append(a)
  i = 1
  c = 0
  while c!=b and i<(m+1)//2:
      if i!=a and m+1-i!=a:
          check.append(i)
          check.append(m+1-i)
          c+=1
      i+=1
  if c==b:
      for i in check:
          print(i)
  else:

      n-=(m+1)//2
      a = n % (m + 1)
      b = n // (m + 1)
      if m % 2 == 0:
          if a != 0:
              print(a)
          i = 1
          c = 0
          while c != b:
              if i != a and m + 1 - i != a:
                  print(i)
                  print(m + 1 - i)
                  c += 1
      """
    print(m)
    n -= m
    m -= 1

    a = n % (m + 1)
    b = n // (m + 1)
    if a != 0:
        print(a)
        i = 1
        c = 0
        while c != b:
            if i != a and m + 1 - i != a:
                print(i)
                print(m + 1 - i)
                c += 1
            i += 1




### FIXED CODE ###

import math

n = int(input())


def ts(x):
    return x * (x + 1)


m = n
for i in range(math.ceil(math.sqrt(2 * n) - 2), math.floor(math.sqrt(2 * n)) + 1, 1):
    if ts(i) < 2 * n <= ts(i + 1):
        m = i + 1
        break



if m % 2 == 0:
    a = n % (m + 1)
    b = n // (m + 1)
    if a != 0:
        print(a)
    i = 1
    c = 0
    while c != b:
        if i != a and m + 1 - i != a:
            print(i)
            print(m + 1 - i)
            c += 1
        i += 1
else:
    """
  check=[]
  if a!=0:
      check.append(a)
  i = 1
  c = 0
  while c!=b and i<(m+1)//2:
      if i!=a and m+1-i!=a:
          check.append(i)
          check.append(m+1-i)
          c+=1
      i+=1
  if c==b:
      for i in check:
          print(i)
  else:

      n-=(m+1)//2
      a = n % (m + 1)
      b = n // (m + 1)
      if m % 2 == 0:
          if a != 0:
              print(a)
          i = 1
          c = 0
          while c != b:
              if i != a and m + 1 - i != a:
                  print(i)
                  print(m + 1 - i)
                  c += 1
      """
    print(m)
    n -= m
    m -= 1

    a = n % (m + 1)
    b = n // (m + 1)
    if a != 0:
        print(a)
    i = 1
    c = 0
    while c != b:
        if i != a and m + 1 - i != a:
            print(i)
            print(m + 1 - i)
            c += 1
        i += 1
N = int(input())
H = list(map(int, input().split()))

ans = 0
count = 0
for i in range(N):
    if H[i] >= H[i + 1]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print(0)
else:
    ans = 0
    H1 = H[0]
    H2 = H[1]
    count = 1
    move = 0
    while count != N:
        count += 1
        if H2 <= H1:
            move += 1
            ans = max(ans, move)
        else:
            move = 0
        if count != N:
            H1 = H2
            H2 = H[count]

    print(ans)
N = int(input())
h = list(map(int, input().split()))


# DP 最小化問題用 change minimum
# 2つの引数をとり，1つめより2つめが小さかったら更新する

def chmin(array, x):
    if (array > x):
        array = x
        return array
    return array


# DP 最大化問題用 change maximum

def chmax(array, x):
    if (array > x):
        array = x
        return True
    return False


#大きな値
INF = 999999

# DPtable
dp = [INF]*10000

#初期条件
dp[0] = 0

#ループ
for i in range(N):
    if i == 0:
        continue
    else:
        dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
        if i>1:
            dp[i] = chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]))

# print(dp[0:N])
print(dp[N-1])


### FIXED CODE ###

# N = int(input())
# h = list(map(int, input().split()))
# 
# #大きな値
# INF = 9999
# 
# # DPtable
# dp = [INF]*9999
# 
# #初期条件
# dp[0] = 0
# dp[1] = abs(h[1]-h[0])
# 
# #ループ
# for i in range(N):
#     if i == 0 or i == 1:
#         continue
#     else:
#         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
# 
# print(dp[N-1])

N = int(input())
h = list(map(int, input().split()))
dp = [10 ** 10 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])
A, B = map(int, input().split())

import math

print(str((A * B)//math.gcd(A, B)))

### FIXED CODE ###

from fractions import gcd

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

print(str((A * B) // gcd(A, B)))
s=[]
t=[]
for i in S:
    s.append(i)
for i in T:
    t.append(i)
l=[]
for i in range(n):
    l.append(s[i])
    l.append(t[i])
t=""
for i in range(len(l)):
    t+=l[i]
print(t)

### FIXED CODE ###

n=int(input())
S,T=map(str,input().split())

s=[]
t=[]
for i in S:
    s.append(i)
for i in T:
    t.append(i)
l=[]
for i in range(n):
    l.append(s[i])
    l.append(t[i])
t=""
for i in range(len(l)):
    t+=l[i]
print(t)
N=input()

if N%2==0:
    print(N/2)

elif N%2==1:
    print(int(N/2)+1)

### FIXED CODE ###

N=int(input())

if N%2==0:
    print(int(N/2))

elif N%2==1:
    print(int(int(N/2)+1))
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log2(K / k))
        pro += 0.5**r / N
    print(pro)



### FIXED CODE ###

import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = MI()
k = K.bit_length()
AB = []
for _ in range(N):
    a,b = MI()
    if a > K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K = [(K >> i) & 1 for i in range(k-1,-1,-1)]

A = [[] for _ in range(k+1)]
B = [0]*(k+1)
for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if a[j] == 1:
            B[j+1] -= b
        if a[j] > K[j]:
            A[j].append(b)
            break
    else:
        A[k].append(b)


for i in range(k+1):
    A[i] = sum(A[i])

for i in range(k-1,-1,-1):
    A[i] += A[i+1]

c = 0
for i in range(N):
    a,b = AB[i]
    if a[0] == 0:
        c += b

print(max(c,max(A[i]+B[i] for i in range(1,k+1))))


### FIXED CODE ###

import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K = MI()
K += 1
k = K.bit_length()

AB = []

for _ in range(N):
    a,b = MI()
    if a >= K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K_bit = [(K >> i) & 1 for i in range(k-1,-1,-1)]

ANS = [0]*k  # 

for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if K_bit[j] == 1:
            if a[j] == 0:
                ANS[j] += b
        else:
            if a[j] == 1:
                break

print(max(ANS))
import math

a,b,c,d=map(int,input().split())

gcd = int(math.gcd(c,d))

cc = (c//gcd * d)


mm1 = b//c
mm2 = b//d
mmc = b//cc
A1 = b - (mm2 + mm1 - mmc)
# print(A1, b, mm2, mm1, mmc)

a-=1
mm1 = a//c
mm2 = a//d
mmc = a//cc
A2 = a - (mm2 + mm1 - mmc)
# print(A2, a, mm2, mm1, mmc)


print(A1 - A2)

### FIXED CODE ###

import math

a,b,c,d=map(int,input().split())

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

gcd_ = int(gcd(c,d))

cc = (c//gcd_ * d)


mm1 = b//c
mm2 = b//d
mmc = b//cc
A1 = b - (mm2 + mm1 - mmc)
# print(A1, b, mm2, mm1, mmc)

a-=1
mm1 = a//c
mm2 = a//d
mmc = a//cc
A2 = a - (mm2 + mm1 - mmc)
# print(A2, a, mm2, mm1, mmc)


print(A1 - A2)
A,B=map(int,input().split)
print(max([A+B,A-B,A*B]))

### FIXED CODE ###

A,B=map(int,input().split())
x=[A+B,A-B,A*B]
print(max(x))
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    # MOD = 10 ** 9 + 7
    A.sort()
    s = set()

    ans = 0
    if A[0] != A[1]:
        ans += 1

    for i in range(1, n):
        if A[i - 1] == A[i]:
            continue

        for j in range(i):
            if j in s:
                continue
            elif A[i] % A[j] == 0:
                s.add(i)
                break
        else:
            ans += 1
            # print(f"{i = }, {j = }, {ans = }")

    print(ans)


if __name__ == '__ma

### FIXED CODE ###

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


def main():
    n = int(input())
    A = np.array([int(i) for i in input().split()])

    max_dp = np.max(A) + 1
    dp = np.zeros(max_dp, dtype="int32")

    for a in A:
        if dp[a] >= 2:
            continue
        fancy = np.arange(a, max_dp, a)
        dp[fancy] += 2
        dp[a] -= 1
    print(np.sum(dp == 1))


if __name__ == '__main__':
    main()
a,b = map(int,input().split())
c = []
for _ in range(a):
	c.append(int(input()))
sort(c)
print(sum(c[0:b]))

### FIXED CODE ###

a,b = map(int,input().split())
c = list(map(int,input().split()))
c.sort()
print(sum(c[0:b]))
a.b.c=(int(i) for i in input().split())
if b+1>c:
  print(b+c)
else:
  if a+1>c-b:
    print(2*b+c)
  else:
    print(2b+a+1)

### FIXED CODE ###

a,b,c=(int(i) for i in input().split())
if b+1>=c:
  print(b+c)
else:
  if a+1>=c-b:
    print(b+c)
  else:
    print(2*b+a+1)
a = list(map(int, intput().split()))
a.sort()
if a = [5, 5, 7]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
if a == [5, 5, 7]:
  print("YES")
else:
  print("NO")
a,b,c=map(int,input().split())
L=[]
for i in range(c):
  L.append(a+i)
  for j in range(c):
    L.append(b-j)
  
   print(list(set(L)))

### FIXED CODE ###

A,B,K = map(int, input().split())
 
 

 
 
ans = []
for x in range(A, min(A+K,B+1)):
    ans.append(x)
for x in range(max(A,B-K+1), B+1):
    ans.append(x)
for x in sorted(list(set(ans))):
    print(x)
from heapq import heappush,heappop

n,m=[int(x) for x in input().rstrip().split()]
ab=[[] for i in range(10**5)]

for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a<=m:
    ab[m-a].append(-b)

ans=0
time=0
l=[]
for i in range(m,-1,-1):
  for b in ab[i]:
    heappush(l,b)

  if l:
    ans-=heappop(l)

print(ans)


### FIXED CODE ###

from heapq import heappush,heappop

n,m=[int(x) for x in input().rstrip().split()]
ab=[[] for i in range(10**5)]

for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  ab[a-1].append(-b)

ans=0
time=0
l=[]
for i in range(m):
  for b in ab[i]:
    heappush(l,b)
  if l:
    ans-=heappop(l)

print(ans)
N = int
a = (N/1000-int(N/1000))*1000
print(a)


### FIXED CODE ###

N = int(input())
a = N % 1000
b = 1000 - a if a!=0 else 0
print(b)
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dic = {0 : 0, 1 : abs(arr[0]-arr[1])}
	def func(arr, n):
		if n in dic:
			return(dic[n])
		min_path = min(abs(arr[n]-arr[n-1])+func(arr,n-1), abs(arr[n]-arr[n-2])+func(arr,n-2))
		dic[n] = min_path
		return(min_path) 


	print(func(arr, n-1))
	# print(dic)




if __name__ == "__main__":
	a()

### FIXED CODE ###

import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def a():
	n = int(inp()); arr = read()
	dp = [0 for i in range(n)]
	dp[0] = 0
	dp[1] = abs(arr[1]-arr[0])
	for i in range(2, n):
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]))
	print(dp[n-1])




if __name__ == "__main__":
	a()
N = int(raw_input())
A = []
B = []

def insert(B, x):
    B.insert(0, x)
    return B
def delete(B, x):
    i = 0
    for num in B:
        if num == x:
            B.pop(i)
            break
        i += 1
    return B
def deleteFirst(B):
    B.pop(0)
    return B
def deleteLast(B):
    B.pop()
    return B
operation = {'insert':insert, 'delete':delete, 'deleteFirst':deleteFirst, 'deleteLast':deleteLast}

for i in range(N):
    a = raw_input().split()
    if len(a) == 2:
        A.append([a[0], int(a[1])])
    else:
        A.append([a[0]])


for item in A:
    if len(item) == 2:
        command, num = item
        B = operation[command](B, num)
    else:
        command = item[0]
        B = operation[command](B)

print B

### FIXED CODE ###

N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)

A = []
B = []

for i in range(N):
    a = raw_input().split()
    A.append([a[0], int(a[1])])

total_time = 0
while A:
    name, time = A.pop(0)
    if time <= q:
        total_time += time 
        B.append("%s %d" % (name, total_time))
    else:
        time -= q
        A.append([name, time])
        total_time += q
print '\n'.join(B)
n, q=map(int, input().split())
s=input()


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A":
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-1]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-1]-z[l-2]
    print(ans)


### FIXED CODE ###

n, q=map(int, input().split())
s=input()


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A" and i<=n-2:
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-2]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-2]-z[l-2]
    print(ans)
N = int(input())
L = [int(input()) for i in range(N)]
if max(i) < sum(i) - max(i):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
if max(L) < (sum(L) - max(L)):
    print('Yes')
else:
    print('No')
A, B, C, K = map(int, input().split())
if K < A:
    print(K)
elif K =< A+B:
    print(A)
else:
    print(A + (K-A-B)*-1)

### FIXED CODE ###

A, B, C, K = map(int, input().split())
if K < A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(A + (K-A-B)*-1)
import math

a, b, c, d, e, f = map(int, input().split())

highest = 0
sugarwater = 0
maxsugar = 0
for aa in range(math.ceil(f / (100 * a))):
    for cc in range(math.ceil(f / c)):
        for bb in range(math.ceil(f / (100 * b))):
            for dd in range(math.ceil(f / d)):
                sugar = cc * c + dd * d
                water = 100 * (aa * a + bb * b)
                if (
                    sugar == 0
                    or water == 0
                    or sugar / (water / 100) > e
                    or water + sugar > f
                ):
                    continue
                density = 100 * sugar / (water + sugar)
                if density > highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(f"{sugarwater} {maxsugar}")


### FIXED CODE ###

import math

a, b, c, d, e, f = map(int, input().split())

highest = 0
sugarwater = 0
maxsugar = 0
amax = math.ceil(f / (100 * a))
bmax = math.ceil(f / (100 * b))
cmax = math.ceil(30 * e / c)
dmax = math.ceil(30 * e / d)
for aa in range(amax):
    for bb in range(bmax):
        water = 100 * (aa * a + bb * b)
        if water == 0 or water > f:
            continue
        for cc in range(cmax):
            for dd in range(dmax):
                sugar = cc * c + dd * d
                if sugar / (water / 100) > e or water + sugar > f:
                    continue
                density = 100 * sugar / (water + sugar)
                if density >= highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
dp=[0]*(n+1)
j=-1
for i in range(n,-1,-1):
  if i==a[j]:
    if m>j*(-1):
      j-=1
  else:
    if i==n or i==n-1:
      dp[i]=1
    else:
      dp[i]=dp[i+1]+dp[i+2]
print(dp[0]%1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
dp=[0]*(n+1)
if m==0:
  for i in range(n,-1,-1):
    if i==n or i==n-1:
      dp[i]=1
    else:
      dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)
else:
  j=-1
  for i in range(n,-1,-1):
    if i==a[j]:
      if m>j*(-1):
        j-=1
    else:
      if i==n or i==n-1:
        dp[i]=1
      else:
        dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)
n, m = map(int, input().split())
table = [[] for i in range(n+1)]
ans = [(1e9, 0) for i in range(n+1+2)]
def func(node, num, li):
    for i in li:
        if num < ans[i][0]:
            ans[i] = (num, node)
            func(i, num+1, table[i])
        # print(ans[2:])


# print(table)
for i in range(m):
    a, b = map(int, input().split())
    # print(table[min(a, b)])
    # table[min(a, b)].append(max(a, b))
    table[a].append(b)
    table[b].append(a)

# print(table)


num = 1



func(1, num, table[1])
# print(ans[2:])
ans_ = []
for i in ans[2:]:
    ans_.append(i[1])
# print(ans_)
if 1e9 in ans_:
    print("No")
else:
    print("Yes")
    for i in ans_:
        print(i)


# print(table)


### FIXED CODE ###

import queue

n, m = map(int, input().split())
table = [[] for i in range(n+1)]
ans = [(1e9, 0) for i in range(n+1)]
seen = [False for _ in range(n+1)]
seen[1] = True

for i in range(m):
    a, b = map(int, input().split())
    # print(table[min(a, b)])
    # table[min(a, b)].append(max(a, b))
    table[a].append(b)
    table[b].append(a)

q = queue.Queue()

q.put((1, table[1]))
while(not q.empty()):
    element = q.get()
    for i in element[1]:
        if seen[i]:
            continue
        ans[i] = element[0]
        seen[i] = True
        q.put((i, table[i]))


if 1e9 in ans[2:]:
    print("No")
else:
    print("Yes")
    for i in ans[2:]:
        print(i)
def process():
    data = []
    for line in get_data():
        line = line.split()
        if len(line) == 2:
            if line[0] == line[1] == '0':
                data = []
                continue
            H = int(line[0])
            W = int(line[1])
        elif len(line) == 0:
            pass
        else:
            data.append(line[0])
            if len(data) == H:
                field = create_field(H, W)
                print search(H, W, data, field)


def search(H, W, data, field):
    count = 0
    for i in xrange(H):
        for j in xrange(W):
            if field[i][j] == 0:
                continue
            _search(i, j, H, W, data[i][j], data, field)
            count += 1
    return count


def _search(i, j, H, W, cell, data, field):
    field[i][j] = 0
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if field[a][b] == 0:
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data, field)
    return


def create_field(H, W):
    field = []
    for i in xrange(H):
        raw = []
        for j in xrange(W):
            raw.append(1)
        field.append(raw)
    return field


def get_data():
    return [line.strip() for line in raw_input()]


if __name__ == "__main__":
    process()

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()
a, b = map(str, input.split())
if a == b:
    print('H')
else:
    print('D')

### FIXED CODE ###

a, b = map(str, input().split())
if a == b:
    print('H')
else:
    print('D')