Buggy python submission (verdict: Runtime Error):
ans = {}

roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    for i in range(len(str1)):
        ans[i, -1] = 0
    for j in range(len(str2)):
        ans[-1, j] = 0
    for i in range (len(str1)):
        for j in range(len(str2)):
            if(str1[i] == str2[j]):
                ans[i, j] = ans[i - 1, j - 1] + 1
            else:
                ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
    print ans[len(str1) - 1, len(str2) - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
ans = {}

roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    for i in range(len(str1)):
        ans[i, -1] = 0
    for j in range(len(str2)):
        ans[-1, j] = 0
    ans[-1, -1] = 0
    for i in range (len(str1)):
        for j in range(len(str2)):
            if(str1[i] == str2[j]):
                ans[i, j] = ans[i - 1, j - 1] + 1
            else:
                ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
    print ans[len(str1) - 1, len(str2) - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
ans = {}

roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    for i in range (-1, len(str1)):
        for j in range(-1, len(str2)):
            if(i == -1 or j == -1):
                ans[i, j] = 0
            else:   
                if(str1[i] == str2[j]):
                    ans[i, j] = ans[i - 1, j - 1] + 1
                else:
                    ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
    print ans[len(str1) - 1, len(str2) - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
ans = {}

roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1)
    len2 = len(str2)
    
    for i in xrange (-1, len1):
        for j in xrange(-1, len2):
            if(i == -1 or j == -1):
                ans[i, j] = 0
            else:   
                if(str1[i] == str2[j]):
                    ans[i, j] = ans[i - 1, j - 1] + 1
                else:
                    ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
    print ans[len(str1) - 1, len(str2) - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    ans = [None] * (len1)
    for i in xrange(len1):
        ans[i] = [None] * (len2)
    for i in range(len1):
        ans[i][0] = 0
    for j in range(len2):
        ans[0][j] = 0
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Runtime Error):
ans = [None] * 1000
for i in xrange(1000):
    ans[i] = [None] * 1000
for i in range(len1):
        ans[i][0] = 0
    for j in range(len2):
        ans[0][j] = 0
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Runtime Error):
ans = [None] * 1000
for i in xrange(1000):
    ans[i] = [None] * 1000
for i in range(1000):
        ans[i][0] = 0
    for j in range(1000):
        ans[0][j] = 0
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Runtime Error):
ans = [None] * 1000
for i in xrange(1000):
    ans[i] = [None] * 1000
for i in range(1000):
    ans[i][0] = 0
for j in range(1000):
    ans[0][j] = 0
    
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
ans = [None] * 1001
for i in xrange(1001):
    ans[i] = [None] * 1001
for i in range(1001):
    ans[i][0] = 0
for j in range(1001):
    ans[0][j] = 0
    
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Runtime Error):
ans = [None] * 1000
for i in xrange(1000):
    ans[i] = [None] * 1000
for i in range(1000):
    ans[i][0] = 0
for j in range(1000):
    ans[0][j] = 0
    
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
ans = [None] * 1001
for i in xrange(1001):
    ans[i] = [None] * 1001
for i in range(1001):
    ans[i][0] = 0
for j in range(1001):
    ans[0][j] = 0
    
roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1) + 1
    len2 = len(str2) + 1
    for i in range (1, len1):
        for j in range(1, len2):
            if(str1[i - 1] == str2[j - 1]):
                ans[i][j] = ans[i -1][j - 1] + 1
            else:
                ans[i][j] = max(ans[i - 1][j], ans[i][j - 1])
    print ans[len1 - 1][len2 - 1]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
for k in xrange(n):
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
            if str1[i - 1] == str2[j - 1]:
                after[j] = before[j - 1] + 1
            else:
                after[j] = max(before[j], after[j - 1])
    print after[j]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
for k in xrange(n):
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
            if str1[i - 1] == str2[j - 1]:
                after[j] = before[j - 1] + 1
            elif after[j - 1] > before[j]:
                after[j] = after[j - 1]
    print after[j]

Fixed submission:
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()