Dictionary<int, Dictionary<int, int>>は効率悪いな
struct Key { public int M; public int N; public override int GetHashCode() { return M ^ N } }
こういうのをキーにしたらDictionary<Key, int>で済むのに