Problem: A wavy number is such positive integer that for any digit of its decimal representation except for the first one and the last one following condition holds: the digit is either strictly larger than both its adjacent digits or strictly less than both its adjacent digits. For example, numbers 35270, 102, 747, 20 and 3 are wavy and numbers 123, 1000 and 2212 are not.

The task is to find the k-th smallest wavy number r that is divisible by n for the given integer values n and k.

You are to write a program that will find the value of r if it doesn't exceed 1014.

Input

The only line of input contains two integers n and k, separated by a single space (1 ≤ n, k ≤ 1014). 

Output

Your task is to output the only integer r — the answer to the given problem. If such number does not exist or it is larger than 1014, then print "-1" (minus one without the quotes) instead.

Examples

Input

123 4


Output

1845


Input

100 1


Output

-1


Input

97461 457


Output

1805270103

Note

The values of the first four wavy numbers that are divisible by n for the first sample are: 492, 615, 738 and 1845.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int check(int x) {
  if (x < 100) x += x % 10 * 100;
  while (x >= 100) {
    int y = x % 1000, a = y % 10, b = y / 10 % 10, c = y / 100;
    if ((b - a) * (b - c) <= 0) return 0;
    x /= 10;
  }
  return 1;
}
int check(long long x) {
  while (x >= 100) {
    int y = x % 1000, a = y % 10, b = y / 10 % 10, c = y / 100;
    if ((b - a) * (b - c) <= 0) return 0;
    x /= 10;
  }
  return 1;
}
inline int front(int x) { return x / 1000000; }
inline int last(int x) { return x % 10; }
inline int typea(int x) { return x / 1000000 > x / 100000 % 10; }
inline int typeb(int x) { return x / 10 % 10 > x % 10; }
char ccounter[10][2][10000010];
int counter[10][2][1010];
int flag;
int main() {
  long long n, k, c = 0;
  scanf("%I64d%I64d", &n, &k);
  if (n >= 9000000) {
    long long i = n;
    int j = 1;
    while (i <= 100000000000000LL) {
      if (check(i) && ++c == k) {
        printf("%I64d\n", i);
        return 0;
      }
      ++j;
      i += n;
    }
    puts("-1");
    return 0;
  }
  for (int i = 1; i < 10000000; ++i) {
    if (i < 100 || check(i)) {
      if (i % 10 == i / 10 % 10) continue;
      if (i % n == 0 && ++c == k) {
        printf("%d\n", i);
        return 0;
      }
      if (i >= 1000000)
        n <= 1000 ? ++counter[front(i)][typea(i)][i % n]
                  : ++ccounter[front(i)][typea(i)][i % n];
      else if (i >= 100000 && i / 100000 > i / 10000 % 10)
        n <= 1000 ? ++counter[0][0][i % n] : ++ccounter[0][0][i % n];
    }
  }
  long long ff;
  for (int i = 1; i < 10000000; ++i) {
    if (check(i)) {
      int last = i % 10, mod = n - i * 10000000LL % n;
      int sum = 0;
      if (mod == n) mod = 0;
      if (i < 10)
        for (int j = 0; j < 10; ++j) {
          if (j == i) continue;
          sum += n <= 1000 ? counter[j][j > i][mod] : ccounter[j][j > i][mod];
        }
      else if (!typeb(i))
        for (int j = 0; j < last; ++j)
          sum += n <= 1000 ? counter[j][0][mod] : ccounter[j][0][mod];
      else
        for (int j = last + 1; j < 10; ++j)
          sum += n <= 1000 ? counter[j][1][mod] : ccounter[j][1][mod];
      if (c + sum >= k) {
        flag = 1;
        ff = i * 10000000LL;
        break;
      } else
        c += sum;
    }
  }
  if (flag) {
    for (; c < k; ++ff)
      if (check(ff) && ff % n == 0) ++c;
    printf("%I64d\n", ff - 1);
  } else
    puts("-1");
  return 0;
}