n = int(eval(input()))

s = [0] * n

inc = [[] for _ in range(1100000)]

zeros = []

dec = [[] for _ in range(1100000)]



for i in range(n):

    s[i] = eval(input())

    start = 0

    minimum = 0

    now = 0

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        minimum = min(minimum, now)

    end = now

    

    if end == 0:

        zeros.append(i)

    elif start < end:

        inc[minimum].append(i)

    else:

        minimum = minimum - end

        dec[minimum].append(i)



now = 0

for m in range(0, -1000000, -1):

    for i in inc[m]:

        for c in s[i]:

            if c == '(':now += 1

            else: now -= 1

            if now < 0:

                print("No")

                exit()

        

for i in zeros:

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        if now < 0:

            print("No")

            exit()

            

for m in range(-1000000, 1):

    for  i in dec[m]:

        for c in s[i]:

            if c == '(':now += 1

            else: now -= 1

            if now < 0:

                print("No")

                exit()

                

if now != 0:

    print("No")

else:

    print("Yes")
n = int(eval(input()))

s = [0] * n

inc = []

zeros = []

dec = []



for i in range(n):

    s[i] = eval(input())

    start = 0

    minimum = 0

    now = 0

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        minimum = min(minimum, now)

    end = now

    

    if end == 0:

        zeros.append((minimum, i))

    elif start < end:

        inc.append((minimum, i))

    else:

        minimum = minimum - end

        dec.append((minimum, i))



inc.sort(reverse=True)

dec.sort()





now = 0

for (m, i) in inc:

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        if now < 0:

            print("No")

            exit()

        

for (m, i) in zeros:

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        if now < 0:

            print("No")

            exit()



for (m, i) in dec:

    for c in s[i]:

        if c == '(':now += 1

        else: now -= 1

        if now < 0:

            print("No")

            exit()



if now != 0:

    print("No")

else:

    print("Yes")

n = int(eval(input()))
s = [0] * n
inc = [[] for _ in range(1100000)]
zeros = []
dec = [[] for _ in range(1100000)]
for i in range(n):
    s[i] = eval(input())
    start = 0
    minimum = 0
    now = 0
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        minimum = min(minimum, now)
    end = now
    if end == 0:
        zeros.append(i)
    elif start < end:
        inc[minimum].append(i)
    else:
        minimum = minimum - end
        dec[minimum].append(i)
now = 0
for m in range(0, -1000000, -1):
    for i in inc[m]:
        for c in s[i]:
            if c == "(":
                now += 1
            else:
                now -= 1
            if now < 0:
                print("No")
                exit()
for i in zeros:
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        if now < 0:
            print("No")
            exit()
for m in range(-1000000, 1):
    for i in dec[m]:
        for c in s[i]:
            if c == "(":
                now += 1
            else:
                now -= 1
            if now < 0:
                print("No")
                exit()
if now != 0:
    print("No")
else:
    print("Yes")

n = int(eval(input()))
s = [0] * n
inc = []
zeros = []
dec = []
for i in range(n):
    s[i] = eval(input())
    start = 0
    minimum = 0
    now = 0
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        minimum = min(minimum, now)
    end = now
    if end == 0:
        zeros.append((minimum, i))
    elif start < end:
        inc.append((minimum, i))
    else:
        minimum = minimum - end
        dec.append((minimum, i))
inc.sort(reverse=True)
dec.sort()
now = 0
for (m, i) in inc:
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        if now < 0:
            print("No")
            exit()
for (m, i) in zeros:
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        if now < 0:
            print("No")
            exit()
for (m, i) in dec:
    for c in s[i]:
        if c == "(":
            now += 1
        else:
            now -= 1
        if now < 0:
            print("No")
            exit()
if now != 0:
    print("No")
else:
    print("Yes")

-inc = [[] for _ in range(1100000)] +inc = [] -dec = [[] for _ in range(1100000)] +dec = [] -        zeros.append(i) +        zeros.append((minimum, i)) -        inc[minimum].append(i) +        inc.append((minimum, i)) -        dec[minimum].append(i) +        dec.append((minimum, i)) +inc.sort(reverse=True) +dec.sort() -for m in range(0, -1000000, -1): -    for i in inc[m]: -        for c in s[i]: -            if c == "(": -                now += 1 -            else: -                now -= 1 -            if now < 0: -                print("No") -                exit() -for i in zeros: +for (m, i) in inc: -for m in range(-1000000, 1): -    for i in dec[m]: -        for c in s[i]: -            if c == "(": -                now += 1 -            else: -                now -= 1 -            if now < 0: -                print("No") -                exit() +for (m, i) in zeros: +    for c in s[i]: +        if c == "(": +            now += 1 +        else: +            now -= 1 +        if now < 0: +            print("No") +            exit() +for (m, i) in dec: +    for c in s[i]: +        if c == "(": +            now += 1 +        else: +            now -= 1 +        if now < 0: +            print("No") +            exit()