Harryxun/stf_run huggingface dataset:
from itertools import product, combinations
from collections import Counter


def solve():
    N = int(input())
    *D, = map(int, input().split())

    l, m = [], []
    for i, j in Counter(D).items():
        if j>=3 or (i==12 and j>=2) or i==0:
            print(0)
        elif j==2:
            l += [i]
        elif j==1:
            m += [i]

    size = len(m)
    ans = 0

    g = lambda x: min(x, 24-x)

    for i in product(range(2), repeat=size):
        c = [m[j] if k else 24-m[j] for j, k in enumerate(i)]
        f = lambda x, y: g(abs(c[x]-c[y]))
        for j in l:
            c.append(j)
            c.append(24-j)

        a = min(map(g, c))
        b = min(f(j, k) for j, k in combinations(range(N), 2))
        ans = max(ans, min(a, b))

    print(ans)

if __name__ == "__main__":
    solve()



### FIXED CODE ###

from itertools import product
from collections import Counter


def solve():
    N = int(input())
    *D, = map(int, input().split())

    l, m = [], []
    for i, j in Counter(D).items():
        if j>=3 or (i==12 and j>=2) or i==0:
            print(0)
            return
        elif j==2:
            l.append(i)
        elif j==1:
            m.append(i)

    size = len(m)
    ans = 0

    for i in product(range(2), repeat=size):
        c = []
        for j, k in enumerate(i):
            if k:
                c.append(m[j])
            else:
                c.append(24-m[j])
        for j in l:
            c.append(j)
            c.append(24-j)

        v = 24
        for j in c:
            d = min(j, 24-j)
            v = min(v, d)

        for j in range(N):
            for k in range(j+1, N):
                d = abs(c[j]-c[k])
                v = min(v, min(d, 24-d))
        ans = max(ans, v)

    print(ans)


if __name__ == "__main__":
    solve()
def prepare(n,arr):
    nodeArr = [[] for i in range(n)]
    for ar in arr:
        nodeArr[ar[0]-1].append([ar[1]-1,ar[2]])
        nodeArr[ar[1]-1].append([ar[0]-1,ar[2]])
    return nodeArr

def dfs(parent,currentNode,distance):

    if len(nodeArr[currentNode]) == 1:
        if currentNode != 0:
            # 末点
            res[currentNode] = distance
            return

    for next in nodeArr[currentNode]:
        nextNode = next[0]
        nextNodeDistance = next[1]
        if nextNode == parent:
            continue
        dfs(currentNode,nextNode,distance + nextNodeDistance)
        res[currentNode] = distance


n = int(input())

arr = []

for i in range(n-1):
    arr.append([int(s) for s in input().split(" ")])

nodeArr = prepare(n, arr)


if n == 1:
    print(1)
else:
    res = [-1 for i in range(n)]

    dfs(-1,0,0)

    result = [(re % 2) for re in res]

    for re in res:
        print(re % 2)



### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)
def prepare(n,arr):
    nodeArr = [[] for i in range(n)]
    for ar in arr:
        nodeArr[ar[0]-1].append([ar[1]-1,ar[2]])
        nodeArr[ar[1]-1].append([ar[0]-1,ar[2]])
    return nodeArr

def dfs(currentNode,distance):
    res[currentNode] = distance
    for next in nodeArr[currentNode]:
        nextNode = next[0]
        nextNodeDistance = next[1]
        if res[nextNode] == -1:
            dfs(nextNode,distance + nextNodeDistance)




n = int(input())

arr = []

for i in range(n-1):
    arr.append([int(s) for s in input().split(" ")])

nodeArr = prepare(n, arr)


if n == 1:
    print(1)
else:
    res = [-1 for i in range(n)]

    dfs(0,0)

    result = [(re % 2) for re in res]

    for re in res:
        print(re % 2)
mod = 10**9 + 7
def go(v):
    global tmp
    tmp += 1
    used[v] = True
    for i in range(len(g[v])):
        if not used[g[v][i]]:
            go(g[v][i])
def solve():
    n, m = map(int, input().split())
    global g, used, tmp
    tmp = 0
    g = [[] for i in range(n + 1)]
    ans = 0
    used = [False for i in range(n + 1)]
    for i in range(m):
        x, y = map(int, input().split())
        g[x].append(y)
        g[y].append(x)
    for i in range(1, n + 1):
        if not used[i]:
            tmp = 0
            go(i)
            ans = max(ans, tmp)
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1

### FIXED CODE ###

import sys
sys.setrecursionlimit(200001)
mod = 10**9 + 7
def go(v):
    global tmp
    tmp += 1
    used[v] = True
    for i in range(len(g[v])):
        if not used[g[v][i]]:
            go(g[v][i])
def solve():
    n, m = map(int, input().split())
    global g, used, tmp
    tmp = 0
    g = [[] for i in range(n + 1)]
    ans = 0
    d = {}
    used = [False for i in range(n + 1)]
    for i in range(m):
        x, y = map(int, input().split())
        if (x, y) not in d:
            g[x].append(y)
            g[y].append(x)
            d[(x, y)] = 1
    for i in range(1, n + 1):
        if not used[i]:
            tmp = 0
            go(i)
            ans = max(ans, tmp)
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)


### FIXED CODE ###

def examC():
    N, M = LI()
    A = [I() for _ in range(M)]
    A.append(N+1)
    fib = [1]*(N+2)
    for i in range(1,N):
        fib[i+2] = fib[i+1] + fib[i]
    fib[0] = 0
#    print(fib)
    ans = fib[A[0]]%mod
    for i in range(M):
        ans *= fib[A[i+1]-A[i]-1]
        ans %=mod
    print(ans)
    return

def examD():
    H, W = LI()
    S = [SI() for _ in range(H)]
    width = [[0]*W for _ in range(H)]
    height = [[0]*W for _ in range(H)]
    for i in range(H):
        cur = 0; keep = []
        for j in range(W):
            if S[i][j]==".":
                cur +=1
                keep.append(j)
            else:
                for k in keep:
                    width[i][k] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                width[i][k] = cur
    for j in range(W):
        cur = 0; keep = []
        for i in range(H):
            if S[i][j]==".":
                cur +=1
                keep.append(i)
            else:
                for k in keep:
                    height[k][j] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                height[k][j] = cur
    ans = 0
    for i in range(H):
        for j in range(W):
            cur = width[i][j] + height[i][j]
            if ans<cur:
                ans = cur
    print(ans-1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()
X = [int(i) for i in input().split()]
S = list(input())

S[X[1] - 1] = S[X[1] - 1].lower()

print(''.join(S))

### FIXED CODE ###

X = [int(i) for i in input().split()]
S = list(input())

S[X[1] - 1] = S[X[1] - 1].lower()

print(''.join(S))
A, B = map(int(), input().split())

print(max(A+B, A-B, int(A*B)))

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A+B, A-B, A*B))
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
maze=[]

for i in range(H):
  l=list(input())
  for j in range(len(l)):
    if l[j]=='.':l[j]=-1
    if l[j]=='#':l[j]=-2
  maze.append(l)
def isIn(h,w):
  if h<0 or h>=H or w<0 or w >=W:return False
  return True
def update(maze,h,w,value):
  global update_list
  vectors=[[-1,0],[1,0],[0,1],[0,-1]]
  maze[h][w]=value
  update_list=[]
  u=[]
  for i in range(25):
    if not isIn(h+i//5-2,w+i%5-2):continue
    if maze[h+i//5-2][w+i%5-2]>maze[h][w] or maze[h+i//5-2][w+i%5-2]==-1:
      if [h+i//5-2,w+i%5-2] not in u:
        u.append([h+i//5-2,w+i%5-2])
        maze[h+i//5-2][w+i%5-2]=value+1
  for vector in vectors:
    if not isIn(h+vector[0],w+vector[1]):continue
    if maze[h+vector[0]][w+vector[1]]>maze[h][w] or maze[h+vector[0]][w+vector[1]]==-1:
      maze[h+vector[0]][w+vector[1]]=maze[h][w]
      update(maze,h+vector[0],w+vector[1],value)
      
  for h,w in u:
    if maze[h][w]==value+1 and not [h,w] in update_list:
      update_list.append([h,w])
  return update_list

update_list=update(maze,Ch-1,Cw-1,0)
def calc(update_list):
  for h,w in update_list:
    u=update(maze,h,w,maze[h][w])
    calc(u)
calc(update_list)
print(maze[Dh-1][Dw-1])

### FIXED CODE ###

from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
maze=[]

for i in range(H):
  l=list(input())
  for j in range(len(l)):
    if l[j]=='.':l[j]=-1
    if l[j]=='#':l[j]=-2
  maze.append(l)

def isIn(h,w):
  if h<0 or h>=H or w<0 or w >=W:return False
  return True
l=[[Ch-1,Cw-1]]
l=deque(l)
maze[Ch-1][Cw-1]=0
l2=[[0]*W for i in range(H)]

cnt=0
while l:
  cnt+=1
  vectors=[[-1,0],[1,0],[0,1],[0,-1]]

  target=l[0]
  h,w=target
  l.popleft()
  if l2[h][w]:
    continue
  l2[h][w]=1
  for vector in vectors:
    if not isIn(h+vector[0],w+vector[1]):continue
    if maze[h+vector[0]][w+vector[1]]>maze[h][w] or maze[h+vector[0]][w+vector[1]]==-1:
      maze[h+vector[0]][w+vector[1]]=maze[h][w]
      l.appendleft([h+vector[0],w+vector[1]])
  for i in range(25):
    if not isIn(h+i//5-2,w+i%5-2):continue
    if maze[h+i//5-2][w+i%5-2]>maze[h][w] or maze[h+i//5-2][w+i%5-2]==-1:
      maze[h+i//5-2][w+i%5-2]=maze[h][w]+1
      l.append([h+i//5-2,w+i%5-2])
print(maze[Dh-1][Dw-1])
import numpy as np
import copy

N = int(input())
A = [int(i) for i in input().split()]
A = list(set(A))

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

if N==2:
    print(max(A))
else:
    gcdss = []
    for i,a in enumerate(A):
        A_temp = copy.deepcopy(A)
        A_temp.pop(i)
        gcds = []
        for i in range(len(A_temp)-1):
            gcd_temp = gcd(A_temp[i],A_temp[i+1])
            gcds.append(gcd_temp)
            if gcd_temp == 1:
                break
        gcdss.append(min(gcds))
    print(max(gcdss))

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a  
lgcds = [A[0]]
rgcds = [A[N-1]]
for n in range(N-2):
    lgcds.append(gcd(lgcds[-1],A[n+1]))
    rgcds.append(gcd(rgcds[-1],A[-2-n]))
gcds = [lgcds[-1],rgcds[-1]]
for i in range(N-2):
    gcds.append(gcd(lgcds[i],rgcds[-2-i]))
print(max(gcds))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
Candies=[]
for i in range(n):
    Candies.appned(sum(a[:i+1])+sum(b[i+1:])
print(max(Candies))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
Candies=[]
for i in range(n):
    Candies.append(sum(a[:i+1])+sum(b[i:]))
print(max(Candies))
N = int(input())
K = int(input())
number = 1

for i in N:
    if number * 2 < number + K:
        number = number * 2
    else:
        number = number + K

print(number)

### FIXED CODE ###

N = int(input())
K = int(input())
number = 1

for i in range(N):
    if number * 2 < number + K:
        number = number * 2
    else:
        number = number + K

print(number)
S = list(input())
ans = 0
for i in range(len(S)//2):
 if S[i] = S[len(S)-1-i]:
   continue
 else:
   ans += 1
print(ans)

### FIXED CODE ###

S = list(input())
ans = 0
for i in range(len(S)//2):
 if S[i] == S[len(S)-1-i]:
   continue
 else:
   ans += 1
print(ans)
N=int(input())
shogen=[]
count_ans=[]
for i in range(N):
    A=int(input())
    shogen.append([list(map(int,input().split())) for i in range(A)])
def saiki(A):
    if len(A)==N:
        honest=set()
        honest_kari=set()
        unkind=set()
        count=0
        unkind_kari=set()
        for i in range(N):
            if A[i]==1:
                honest.add(i)
            else:
                unkind.add(i)
        for i in range(N):
            if i in honest:
                for j in range(len(shogen[i])):
                    if shogen[i][j][1]==0:
                        unkind_kari.add(shogen[i][j][0])
                    else:
                        honest_kari.add(shogen[i][j][0])
        for i in honest:
            if i not in unkind_kari:
                if i not in unkind:
                    count+=1
        for i in unkind:
            if i not in honest_kari:
                if i not in honest:
                    count+=1
        if count==len(unkind_kari)+len(honest_kari):
            count_ans.append(len(honest))

        
        return
    for i in range(2):
        A.append(i)
        saiki(A)
        A.pop()
saiki([])
print(max(count_ans))

### FIXED CODE ###

N=int(input())
shogen=[]
count_ans=[]
for i in range(N):
    A=int(input())
    shogen.append([list(map(int,input().split())) for i in range(A)])
#print(shogen)
def saiki(A):
    if len(A)==N:
        honest=set()
        honest_kari=set()
        unkind=set()
        count=0
        unkind_kari=set()
        for i in range(N):
            if A[i]==1:
                honest.add(i)
            else:
                unkind.add(i)
        for i in range(N):
            if i in honest:
                for j in range(len(shogen[i])):
                    if shogen[i][j][1]==0:
                        unkind_kari.add(shogen[i][j][0]-1)
                    else:
                        honest_kari.add(shogen[i][j][0]-1)
        #print(honest,honest_kari)
        for i in unkind_kari:
            if i in unkind:
                count+=1
        for i in honest_kari:
            if i in honest:
                count+=1
        if count==len(unkind_kari)+len(honest_kari):
            kari=set(list(honest)+list(honest_kari))
            #print(honest,honest_kari,count)
            count_ans.append(len(kari))

        
        return
    for i in range(2):
        A.append(i)
        saiki(A)
        A.pop()
saiki([])
print(max(count_ans))
a,b,c = raw_input().split()

arr = [a,b,c]

print(arr[2],arr[0],arr[1])

### FIXED CODE ###

a,b,c = input().split()
print(str(c)+" "+str(a)+" "+str(b))
import numpy as np

def koch_divide(p,q):
    v = q-p
    r = np.array([[0.866, 0.5],[-0.5, 0.866]])
    s = p + v/3
    t = q - v/3
    u = p + np.dot(v,r)/np.sqrt(3)
    return [s,u,t,q]

def koch_curve(previous):
    vertices = [previous[0]]
    for p,q in zip(previous[:-1], previous[1:]):
        vertices.append(koch_divide(p,q))
    return vertices

if __name__=='__main__':
    p_q = np.array([[0.0, 0.0], [100.0, 0.0]])
    n = int(input())
    for _ in range(n):
        p_q = koch_curve(p_q)
    for vertex in p_q:
        print(" ".join(map(str, vertex)))

### FIXED CODE ###

def koch_divide(p,q):
    v = [q[0]-p[0], q[1]-p[1]]
    s = [p[0]+v[0]/3, p[1]+v[1]/3]
    t = [q[0]-v[0]/3, q[1]-v[1]/3]
    u = [p[0]+v[0]*0.5-v[1]*0.288675, p[1]+v[0]*0.288675+v[1]*0.5]
    return [s,u,t,q]

def koch_curve(previous):
    vertices = [previous[0]]
    for p,q in zip(previous[:-1], previous[1:]):
        vertices.extend(koch_divide(p,q))
    return vertices

if __name__=='__main__':
    p_q = [[0.0, 0.0], [100.0, 0.0]]
    n = int(input())
    for _ in range(n):
        p_q = koch_curve(p_q)
    for vertex in p_q:
        print(" ".join(['{:.8f}'.format(x) for x in vertex]))
S = str(input())

print(S[1]+S[2]+S[3])


### FIXED CODE ###

S = str(input())

print(S[0]+S[1]+S[2])
from math import gcd
from functools import reduce
import sys


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n, m = map(int, input().split())
A = list(map(int, input().split()))

max_value = 2 * m

lcm = lcm_list(A)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers, maxvalue):
    first = 1
    second = 1
    for i in numbers:
        second = i
        lcm_result = lcm_base(first, second)
        if lcm_result > max_value:
            return -1
        first = lcm_result
    return lcm_result


n, m = map(int, input().split())
A = list(map(int, input().split()))

max_value = 2 * m

lcm = lcm_list(A, 2 * m)
if lcm == -1:
    print("0")
    sys.exit(0)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)
k,s = [int(i) for i in input().split()]


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:

### FIXED CODE ###

k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)
m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = (int(x) for x in input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)


### FIXED CODE ###

m = int(input())
csum = 0
dsum = 0
for i in range(m):
  d,c = (int(x) for x in input().split())
  csum += c
  dsum += d*c
print(csum-1 + (dsum-1) // 9)
# -*- coding: utf-8 -*-

import sys
import math

def saiki(n,saiki_one_count,do_count):
    do_count += 1
    mod = n % saiki_one_count
    if mod == 0:
        return do_count
    saiki_one_count = bin(mod).count("1")
    return saiki(mod,saiki_one_count,do_count)
def main():
    input = sys.stdin.readline
    N = int(input())
    x = input()
    x_list = list(x)[:-1]
    x_list = [int(value) for value in x_list]
    one_count = x_list.count(1)
    sum_x = 0
    for i in range(len(x_list)):
        if x_list[N -1 - i] == 1:
            sum_x += 2 ** i

    for i in range(len(x_list)):
        current_sum_x = 0
        current_one_count = 0
        if x_list[i] == 0:
            current_one_count = one_count + 1
            current_sum_x = sum_x + 2 ** (N - 1 - i)
        else:
            current_one_count = one_count - 1
            current_sum_x = sum_x - 2 ** (N - 1 - i)
        do_count = saiki(current_sum_x,current_one_count,0)
        print(do_count)
    return


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()
from collections import deque

n, k = map(int, input().split())
A = list(map(int, input().split()))


def check(x):
    return A[x - 1]


x = 1
lis = deque([])
for i in range(n + 2):
    if check(x) in lis:
        break
    else:
        lis.appendleft(check(x))
        x = check(x)

num = lis.index(check(x)) + 1
k = (k - (i - num)) % num
print(lis[- k - (i - num)])


### FIXED CODE ###

s=input()
t=input()
if t[:-1]==s:
  print("Yes")
else:
  print("No")
S = input()

length = len(S)
for i in range(length):
    if (i + 1) % 2 == 0:
        global evenN
        if S[i] == 'R':
            evenN = False
        else:
            evenN = True
    if (i + 1) % 2 == 1:
        global oddN
        if S[i] == 'L':
            oddN = False
        else:
            oddN = True


if oddN is True and evenN is True:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = input()

length = len(S)
evenN = []
oddN = []
for i in range(length):
    if (i + 1) % 2 == 0:
        if S[i] == 'R':
            evenN.append(False)
        else:
            evenN.append(True)
    if (i + 1) % 2 == 1:
        if S[i] == 'L':
            oddN.append(False)
        else:
            oddN.append(True)


if all(oddN) is True and all(evenN) is True:
    print('Yes')
else:
    print('No')
print("YES") if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "" else print("NO")


### FIXED CODE ###

print("YES") if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "" else print("NO")
s = list(input())
for i in range(3):
  	if(s[i] == s[i+1]):
  		print('Bad')
 		exit()
else:
  	print('Good')


### FIXED CODE ###

S = list(input())
for i in range(3):
    if(S[i]==S[i+1]):
        print('Bad')
        exit()
else:
    print('Good')
# -*- coding: utf-8 -*-
import queue

n, x, y = map(int, input().split())
x -= 1
y -= 1
INF = 10010101010101
ans = [0]*n
def put(v, d):
    if dist[v] != INF:
        return
    dist[v] = d
    q.put(v)
for sv in range(n):
    q = queue.Queue()
    dist = [INF for _ in range(n)]
    put(sv, 0)
    while not q.empty():
        v = q.get()
        d = dist[v]
        if v-1 >= 0:
            put(v-1, d+1)
        if v+1 < n:
            put(v+1, d+1)
        if v == x:
            put(y, d+1)
        if v == y:
            put(x, d+1)
    for i in range(n):
        ans[dist[i]] += 1
for i in range(n):
    ans[i] = int(ans[i] / 2)

print(*ans[1:], sep='\n')

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = input()
x = list(s)
if x[2] == x[3]:
    if x[4] == x[5]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
i = 1
while true:
 x = int(input())
 if x == 0:
  break
 print('case %d: %d' % (i,x))
 i +=1


### FIXED CODE ###

i = 1
while True:
 x = int(input())
 if x == 0:
  break
 print('Case %d: %d' % (i,x))
 i +=1
while True:
    a,b = map(int, input().split()))
    if a ==0 and b == 0:
        break
    for i in range(a):
        for i in range(b):
            print("#", end = "")
        print()



### FIXED CODE ###

while True:
    a,b = map(int, input().split())
    if a ==0 and b == 0:
        break
    for i in range(a):
        for i in range(b):
            print("#", end = "")
        print()
    print()