output_description: If a bracket sequence can be formed by concatenating all the N strings in some
  order, print `Yes`; otherwise, print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S_1
      :
      S_N
attempt: N = int(input())
  
  Lflg = 0
  Rflg = 0
  ryohoCnt = 0
  LOver = 0
  
  for i in range(N):
      S = input()
      lnum = S.count("(") - S.count(")")
      konkaiflg = 0
  
      if Lflg < 2 or ryohoCnt < 2:
          if S[0] == "(" and lnum >= 0:
              f = 0
              for j in range(len(S)):
                  if S[0:j].count("(") - S[0:j].count(")") < 0:
                      f = 1
                      break
              if f == 0:
                  Lflg = Lflg + 1
                  konkaiflg = 1
  
      if Rflg < 2 or ryohoCnt < 2:
          if S[-1] == ")" and lnum <= 0:
              f = 0
              for j in range(len(S)):
                  if S[j * (-1)].count("(") - S[j * (-1)].count(")") > 0:
                      f = 1
                      break
              if f == 0:
                  Rflg = Rflg + 1
                  if konkaiflg == 1:
                      ryohoCnt = ryohoCnt + 1
  
      LOver = LOver + lnum
  
  if (
      Lflg >= 1
      and Rflg >= 1
      and LOver == 0
      and not (ryohoCnt == 1 and Lflg == 1 and Rflg == 1)
  ):
      print("Yes")
  else:
      print("No")
  
problem_description: Statement
  
  A **bracket sequence** is a string that is one of the following:
  
    1. An empty string;
    2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ;
    3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B /
  
  Given are N strings S_i. Can a bracket sequence be formed by concatenating all
  the N strings in some order?
samples: [{"input": "2\n    )\n    (()", "output": "Yes\n    \n\nConcatenating `(()` and `)` in this order forms a bracket sequence.\n\n* * *"}, {"input": "2\n    )(\n    ()", "output": "No\n    \n\n* * *"}, {"input": "4\n    ((()))\n    ((((((\n    ))))))\n    ()()()", "output": "Yes\n    \n\n* * *"}, {"input": "3\n    (((\n    )\n    )", "output": "No"}]