Need help with Codejam problem 3 - Cryptopangrams

I logic I thought of was to find gcd of adjacent values to find the prime numbers. It is working for given test cases and others I could think of but it is causing missing key error on line39. I would really appreciate it if someone could help me debug my code: