printРабочее место участника


1032. Better security

Ограничения: время – 2s/4s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Позвонила секретарша босса, говорит, что забыла пароль. Попросил ее поискать его в сумочке, в бардачке машины, в мусорке в дамской комнате. Сказал ей, что он скорее всего вылетел с обратной стороны компьютера. Предложил ей заклеить все вентиляционные отверстия на системном блоке скотчем. Неохотно решил создать ей новую учетную запись, пока она этим занимается.
Young black-hat hacker Vasya routinely installs key loggers on every computer he can get his hands on. Browsing the logs collected, he sometimes can glance passwords of unaware users.
The system administrator of the university where Vasya studies noticed suspicious activity and introduced a new, more secure way to enter passwords. Instead of password input field, window with 9 buttons is displayed. Buttons are arranged into `3\ times\ 3` grid as shown in the table below.
Each button is a square of 100 by 100 pixels. There is no space between buttons. User must enter (digital) password by clicking buttons with a mouse.
To overcome this scheme, Vasya downloaded another cool program: mouse logger. It saves coordinates of clicks in a file, which Vasya is later able to browse. However, a complication has arisen: no information is saved about the position of password window on the screen. Indeed, it might even be partially off screen! Your program must, given the series of mouse clicks, determine all possible corresponding passwords.
Input file contains number of clicks `N` followed by integer coordinates `x_1,\ y_1,\ x_2,\ y_2,\ …,\ x_N,\ y_N`.
Output file must contain one line per possible password. Each line must consist of exactly `N` digits. Lines must be sorted in lexicographical order. If there are no possible combinations, output file must contain the string "NONE".
Constraints `1\ ≤\ N\ ≤\ 100`, `0\ ≤\ x_i\ y_i\ ≤\ 1000`

Sample Input 1

10 12 110 12

Sample Output 1


Sample Input 2

10 12 750 12

Sample Output 2

Source: A. Klenin, I. Ludov, ICPC NEERC Far-Eastern subregional, 2006