Solved the TRGRID problem of Spoj