1372

Problem ID: 1372

See also: UVa 12146, LA 4216, SPOJ SAMER08C