#!/usr/bin/python2
#
# linear-time 3-colorable algorithm <mjd@cs.auckland.ac.nz>  

import sys, re, array

class tOp:
  "A t-parse Operator"
  def __init__(self,tok): self.tok=int(tok)
  def __str__(self): return str(self.tok)
  def isEdgeOp(self): return (self.tok > 9)
  def isVertexOp(self): return (self.tok <= 9)
  def v1(self): return self.tok % 10 # vertex 1
  def v2(self): return self.tok / 10 # vertex 2 if EdgeOp

def rankColoring(C):
  "extract boundary vertex coloring from state index"
  num=0
  for i in range(t+1): num=num*3+C[t-i]
  return num

def unrankColoring(num):
  "extract boundary vertex coloring from state index"
  C=[]
  for i in range(t+1):
    C.append(num % 3); num /= 3;
  return C
  
def pw3Col(pwTokens,state):
  "dynamic program for Pathwidth 3-Colorable"
  for op in pwTokens: 
    o=tOp(op); #print o, 
    if o.isEdgeOp(): 
      v1=o.v1(); v2=o.v2()
      for i in xrange(3**(t+1)): # update all state boundary combinations
        C=unrankColoring(i)
        if C[v1]==C[v2]: state[i]=0 # edge makes invalid coloring
    else: # isVertOp()           
      v1=o.v1()
      for i in xrange(3**(t+1)): 
        C0=unrankColoring(i)
        if C0[v1]==0: # process all coloring states only when v1 is colored 0
           C1=C0; C1[v1]=1; C2=C0; C2[v1]=2; # extract other slices
           i1=rankColoring(C1); i2=rankColoring(C2)
           if max(state[i],state[i1],state[i2])==1: state[i]=state[i1]=state[i2]=1
  return state

def tw3Col(G):
  "dynamic program for Treewidth 3-Colorable"
  G=G.strip(); #print "G=",G
  state=array.array('i', map((lambda n:1), range(3**(t+1))))
  if len(G)==0: return state # state of empty t-parse
  if G[0]!='(': return pw3Col(re.findall('\d+',G),state)
  lev=1
  for i in range(1,len(G)): # doing a circle plus operator
    if G[i]==')': lev-=1
    elif G[i]=='(': lev+=1
    if lev==0: 
      state1=tw3Col(G[1:i-1]) # strip a level of ()'s
      if i+1>=len(G): return state1
      if G[i+1:len(G)].find('(') < 0: # append pathwidth operators?
         return pw3Col(re.findall('\d+',G[i+1:len(G)]),state1)
 
      state2=tw3Col(G[i+1:len(G)]) # recurse remaining half
      state=array.array('i')
      for i in xrange(3**(t+1)): # now update state for circle plus
        state.append(min(state1[i],state2[i]))
      return state

# main program
#
cnt=0
while 1:
  cnt=cnt+1
  s=sys.stdin.readline().strip()              # read input graph

  if s[0]=='0': break
  i=s.find('('); t=int(s[0:i-1]); s=s[i:] # set global treewidth t

  print "Toy "+str(cnt)+(": No",": Yes")[max(tw3Col(s))]

