Go: package main

import (
	"bufio"
	"os"
	"io"
	"strconv"
	"math"
	"fmt"
)

var (
	nstr   func() string
	stdout *bufio.Writer
)

func init() {
	nstr = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func main() {
	defer stdout.Flush()

	n := nint()
	xList := make([]string, n)
	yList := make([]string, n)

	for i:=0;i<n ;i++  {
		xList[i] = nstr()
		yList[i] = nstr()
	}

	for i := 0; i<n	; i++  {
		fmt.Println(lcs(xList[i], yList[i]))
	}

}

func lcs(x string, y string) int{
	var m = len(x)
	var n = len(y)

	c := make([][]int, m+1)
	for i:= range c{
		c[i] = make([]int, n+1)
	}
	for i:=	1;i<=m ;i++  {
		for j:=1;j<=n ;j++  {
			if x[i-1] == y[j-1]{
				c[i][j] = c[i-1][j-1] + 1
			}else{
				c[i][j] = int(math.Max(float64(c[i-1][j]), float64(c[i][j-1])))
			}


		}
	}
	return c[m][n]

}


func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func nint64() int64 {
	i, err := strconv.ParseInt(nstr(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func nint() int {
	return int(nint64())
}

func getIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nint()
	}
	return b
}

func getStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = nstr()
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func bin(i int, prefix bool) string {
	i64 := int64(i)

	if prefix {
		return "0b" + strconv.FormatInt(i64, 2)
	} else {
		return strconv.FormatInt(i64, 2)
	}
}

func strReverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}

Python: def calc_lcs2(X, Y):
    max_lcs = 0
    m = len(X)
    n = len(Y)
    X = ' ' + X
    Y = ' ' + Y
    c = [[0]*(m+1) for i in range(n+1)]
    for i in range(1, m+1):
        for j in range(1, n+1):
            if X[i] == Y[j]:
                c[i][j] = c[i - 1][j - 1] + 1
            elif c[i - 1][j] >= c[i][j - 1]:
                c[i][j] = c[i - 1][j]
            else:
                c[i][j] = c[i][j - 1]
    for row in c:
        max_lcs = max(row)
    return max_lcs



if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    # f = open('input.txt')
    # num = int(f.readline())

    for _ in range(num):
        X = input()
        Y = input()
        # X = f.readline().strip()
        # Y = f.readline().strip()

        # ???????????????
        result = calc_lcs2(X, Y)

        # ???????????¨???
        print(result)

Python: q = int(input())
for _ in range(q):
    x = input()
    y = input()
    m = len(x)
    n = len(y)
    c = [0] * (n + 1)
    for i in range(m):
        tmp = x[i]
        c_ = c[:]
        for j in range(n):
            if tmp == y[j]:
                c[j + 1] = c_[j] + 1
            elif c[j + 1] < c[j]:
                c[j + 1] = c[j]
    print(c[-1])

Python: def lcs_rec(i, j):
    if i == 0 or j == 0:
        return 0

    if X[i - 1] == Y[j - 1]:
        return lcs_rec(i - 1, j - 1) + 1
    else:
        return max(lcs_rec(i - 1, j), lcs_rec(i, j - 1))

q = int(input())

for i in range(q):
    X = input()
    Y = input()

    ans = lcs_rec(len(X), len(Y))

    print(ans)

Python: q = int(input())
for _ in [0]*q:
    s1, s2 = input(), input()
    l1, l2 = len(s1), len(s2)

    dp = [[0]*(l2+1) for _ in [0]*(l1+1)]
    for i, (c1, prev, cur) in enumerate(zip(s1, dp, dp[1:]), start=1):
        for j, (c2, ul, u, l, c) in enumerate(zip(s2, prev, prev[1:], cur, cur[1:]), start=1):
            dp[i][j] = max(ul+(c1==c2), u, l, c)

    print(dp[-1][-1])

Python: def lcs(X,Y):
    Xlength = len(X)
    Ylength = len(Y)

    for i in range(Xlength+1):
        c[i][0] = 0
    for i in range(Ylength+1):
        c[0][i] = 0

    for i in range(Xlength):
        for j in range(Ylength):
            if X[i] == Y[j]:
                c[i+1][j+1] = c[i][j]+1
            else:
                c[i+1][j+1] = max(c[i][j+1],c[i+1][j])

    return c[Xlength][Ylength]

    # print(X,Y)
    # if Xlength == 0 or Ylength == 0:
    #     c[Xlength][Ylength] = 0
    #     return c[Xlength][Ylength]
    #
    #
    #
    # if X[Xlength -1] == Y[Ylength -1]:
    #     if c[Xlength-1][Ylength-1] is not None:
    #         c[Xlength][Ylength] = c[Xlength-1][Ylength-1]+1
    #     else:
    #         c[Xlength][Ylength] = lcs(X[:Xlength-1], Y[:Ylength-1])+1
    # else:
    #     if c[Xlength-1][Ylength] is not None and c[Xlength][Ylength-1] is not None:
    #         c[Xlength][Ylength] = max(c[Xlength][Ylength-1],c[Xlength-1][Ylength])
    #     elif c[Xlength-1][Ylength] is not None:
    #         c[Xlength][Ylength] = max(lcs(X,Y[:Ylength-1]),c[Xlength-1][Ylength])
    #     elif c[Xlength][Ylength-1] is not None:
    #         c[Xlength][Ylength] = max(c[Xlength][Ylength-1],lcs(X[:Xlength-1],Y))
    #     else:
    #         c[Xlength][Ylength] = max(lcs(X,Y[:Ylength-1]),lcs(X[:Xlength-1],Y))
    #
    # return c[Xlength][Ylength]


n = int(input())
X = []
Y = []
c = [[None]*1001 for i in range(1001)]


for i in range(n):
    X.append(input())
    Y.append(input())

for i in range(n):
    # print(i)
    print(lcs(X[i],Y[i]))
    c = [[None]*1001 for i in range(1001)]

Python: def calc(x,y):
    i = len(x)
    j = len(y)
    if not d[i][j] == None:
        return d[i][j]
    else:
        if x[-1] == y[-1]:
            tmp = calc(x[:-1],y[:-1])+1
            d[i][j] = tmp
            return tmp
        else:
            tmp = max(calc(x[:-1],y),calc(x,y[:-1]))
            d[i][j] = tmp
            return tmp
        
q = int(input())
for i in range(q):
    x = input()
    y = input()
    d = [[0 if i == 0 or j == 0 else None for i in range(len(y)+1)] for j in range(len(x)+1)]
    print(calc(x,y))

Python: q = int(input())

for k in range(q):
    x = input()
    y = input()
    lcs = [0]*(len(x)+1)
    for i in range(len(y)):
        w1 = y[i]
        lcs_2 = lcs[:]
        for j in range(len(x)):
            if x[j] == w1:
                lcs[j+1] = lcs_2[j] + 1  
            elif lcs[j+1] < lcs[j]:
                lcs[j+1] = lcs[j]
    print(lcs[-1])

Python: import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
from bisect import bisect_left
for _ in range(N):
    Xs = input()
    Ys = input()[::-1]
    lis = []
    for x in Xs:
        idx = Ys.find(x)+1
        while idx:
            j = bisect_left(lis, -idx)
            if j>=len(lis):
                lis.append(-idx)
            else:
                lis[j] = -idx
            idx = Ys.find(x, idx)+1
    print(len(lis))

Python: def lcs(str1,str2):
    c=[[0 for _ in range(100000000000)] for _ in range(10000000000000)]
    m=len(str1)
    n=len(str2)
    maxl=0
    str1=" "+str1
    str2=" "+str2

    i=1
    j=1
    while(i<=m):
        while(j<=n):
            if(str1[i]==str2[j]):
                c[i][j]=c[i-1][j-1]+1
              #  print(c[i][j])
            else:
                c[i][j]=max(c[i-1][j],c[i][j-1])
            maxl=max(maxl,c[i][j])
            j+=1
        i+=1
        j=0

    return maxl

def main():
    n=int(input())
    i=0
    while(i<n):
        str1=str(input())
        str2=str(input())
        print(int(lcs(str1,str2)))
        i+=1

main()

Python: e=input
a=[]
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[z]
print(*map(len,a),sep='\n')