import sys

readline = sys.stdin.buffer.readline



N = int(readline())

S = [readline().rstrip().decode() for _ in range(N)]



def count_cb_ob(s):

    st = []

    for i, si in enumerate(s):

        if si == '(' or len(st) == 0 or st[-1] != '(':

            st.append(si)

        else:

            st.pop()

    return st.count(')'), st.count('(')



cb_obs = list(map(count_cb_ob, S))

f = list([cb_ob for cb_ob in cb_obs if cb_ob[0] < cb_ob[1]])

b = list([cb_ob for cb_ob in cb_obs if cb_ob[0] > cb_ob[1]])

s = list([cb_ob for cb_ob in cb_obs if cb_ob[0] == cb_ob[1]])



f = sorted(f)

b = sorted(b, key=lambda x:x[1], reverse=True)



count = 0

ans = 'Yes'

for down, up in (*f, *s, *b):

    count -= down

    if count < 0:

        ans = 'No'

    count += up



if count != 0:

    print('No')

else:

    print(ans)
import sys

readline = sys.stdin.readline



N = int(readline())

S = [readline().rstrip() for _ in range(N)]



def count_cb_ob(s):

    st = []

    for i, si in enumerate(s):

        if si == '(' or len(st) == 0 or st[-1] != '(':

            st.append(si)

        else:

            st.pop()

    return st.count(')'), st.count('(')



cb_obs = list(map(count_cb_ob, S))

f, b, s = [], [], []

for down, up in cb_obs:

    (f if down < up else (s if down == up else b)).append((down, up))



f = sorted(f)

b = sorted(b, key=lambda x:x[1], reverse=True)



count = 0

ans = 'Yes'

for down, up in (*f, *s, *b):

    count -= down

    if count < 0:

        ans = 'No'

    count += up



if count != 0:

    ans = 'No'



print(ans)
import sys

readline = sys.stdin.buffer.readline
N = int(readline())
S = [readline().rstrip().decode() for _ in range(N)]


def count_cb_ob(s):
    st = []
    for i, si in enumerate(s):
        if si == "(" or len(st) == 0 or st[-1] != "(":
            st.append(si)
        else:
            st.pop()
    return st.count(")"), st.count("(")


cb_obs = list(map(count_cb_ob, S))
f = list([cb_ob for cb_ob in cb_obs if cb_ob[0] < cb_ob[1]])
b = list([cb_ob for cb_ob in cb_obs if cb_ob[0] > cb_ob[1]])
s = list([cb_ob for cb_ob in cb_obs if cb_ob[0] == cb_ob[1]])
f = sorted(f)
b = sorted(b, key=lambda x: x[1], reverse=True)
count = 0
ans = "Yes"
for down, up in (*f, *s, *b):
    count -= down
    if count < 0:
        ans = "No"
    count += up
if count != 0:
    print("No")
else:
    print(ans)

import sys

readline = sys.stdin.readline
N = int(readline())
S = [readline().rstrip() for _ in range(N)]


def count_cb_ob(s):
    st = []
    for i, si in enumerate(s):
        if si == "(" or len(st) == 0 or st[-1] != "(":
            st.append(si)
        else:
            st.pop()
    return st.count(")"), st.count("(")


cb_obs = list(map(count_cb_ob, S))
f, b, s = [], [], []
for down, up in cb_obs:
    (f if down < up else (s if down == up else b)).append((down, up))
f = sorted(f)
b = sorted(b, key=lambda x: x[1], reverse=True)
count = 0
ans = "Yes"
for down, up in (*f, *s, *b):
    count -= down
    if count < 0:
        ans = "No"
    count += up
if count != 0:
    ans = "No"
print(ans)

-readline = sys.stdin.buffer.readline +readline = sys.stdin.readline -S = [readline().rstrip().decode() for _ in range(N)] +S = [readline().rstrip() for _ in range(N)] -f = list([cb_ob for cb_ob in cb_obs if cb_ob[0] < cb_ob[1]]) -b = list([cb_ob for cb_ob in cb_obs if cb_ob[0] > cb_ob[1]]) -s = list([cb_ob for cb_ob in cb_obs if cb_ob[0] == cb_ob[1]]) +f, b, s = [], [], [] +for down, up in cb_obs: +    (f if down < up else (s if down == up else b)).append((down, up)) -    print("No") -else: -    print(ans) +    ans = "No" +print(ans)