
It’s just a problem to waste your time.
You are given two sequences a1, a2, . . . , an and b1, b2, . . . , bm.
Two sequences (x1, x2, . . . , xp) and (y1, y2, . . . , yq) match iff p = q and xi = xj ⇔ yi = yj for every possible pair 1 ≤ i, j ≤ p.
Output the number of subsequences of a1, a2, . . . , an that match b1, b2, . . . , bm.