#include <bits/stdc++.h>
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
struct node {
  int pos;
  int cnt;
} a[10];
bool cmp(node xx, node yy) { return xx.pos < yy.pos; }
int main() {
  int n, m;
  cin >> n >> m;
  int p[10];
  if (m == 0) {
    if (n == 1) {
      cout << 0;
      return 0;
    } else {
      cout << 1;
      for (int i = 1; i <= n - 1; i++) {
        cout << 0;
      }
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i].pos >> a[i].cnt;
    p[a[i].pos] = a[i].cnt;
  }
  for (int i = 1; i <= m; i++) {
    if (p[a[i].pos] != a[i].cnt) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (n != 1 && a[i].pos == 1 && a[i].cnt == 0) {
      cout << -1;
      return 0;
    }
  }
  char ans[10];
  memset(ans, '0', sizeof(ans));
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    ans[a[i].pos] = a[i].cnt + '0';
  }
  if (ans[1] == 0) {
    ans[1] = '1';
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i];
  }
}
