I might be missing something, but why are you keying the dict with strings like that?
(i,j)
is a perfectly valid dict key.