Python Loop Through Two Strings Codeforces Contest 291