namespace std { template<> struct hash<pair<int, int>> { size_t operator()(const pair<int, int>& a) const { return a.first * MAGIC + a.second; } } }