The basic steps:
1. Create Aho-Corasick dictionary from needle rows.
2. Haystack states: for each row of the haystack, for each character run it through our dictionary and record each state. (That’s one state per character.)
3. Needle fingerprint: for each row of the needle, run it through the dictionary and record the very final state. (That’s one state per row.)
4. Finally, search the haystack states down the columns for the needle fingerprint using KMP.
The implementation is in git and below: