#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  string g;
  for (int i = 0; i < N;) {
    g.push_back('0');
    i++;
  }
  bool can = true;
  int X = 0;
  for (int i = 0; i < M; i++) {
    if (s.at(i) == 1) X++;
    if (s.at(i) == 1 && c.at(i) == 0) {
      can = false;
      break;
    }
  }
  int ans = 0;
  int m = 1;
  if (!can)
    cout << -1 << endl;
  else if (X == 0) {
    g.at(0) = '1';
    for (int i = 0; i < M; i++) g.at(s.at(i) - 1) = c.at(i);
    reverse(g.begin(), g.end());
    for (int i = 0; i < M; i++) {
      ans += g.at(i) * m;
      m *= 10;
    }
    cout << ans << endl;
  } else {
    for (int i = 0; i < M; i++) g.at(s.at(i) - 1) = c.at(i);
    for (int i = 0; i < M; i++) {
      ans += g.at(i) * m;
      m *= 10;
    }
    cout << ans << endl;
  }
}
