CF1228A.Distinct Digits

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Distinct Digits

You have two integers ll and rr. Find an integer xx which satisfies the conditions below:

  • lxrl \le x \le r.
  • All digits of xx are different.

If there are multiple answers, print any of them.

Input

The first line contains two integers ll and rr (1lr1051 \le l \le r \le 10^{5}).

Output

If an answer exists, print any of them. Otherwise, print 1-1.

Note

In the first example, 123123 is one of the possible answers. However, 121121 can't be the answer, because there are multiple 11s on different digits.

In the second example, there is no valid answer.

Samples

121 130
123
98766 100000
-1

在线编程 IDE

建议全屏模式获得最佳体验