Time Limit: 1000ms
Memory Limit: 256MB
Wheatly's portals - Hard version