#include <bits/stdc++.h>
using namespace std;
int vis[15];
int lst;
int a[105];
int main(int argc, char** argv) {
  int n, m;
  cin >> n >> m;
  int s, c;
  int fg = 0, lst = 0;
  memset(vis, -1, sizeof(vis));
  while (m--) {
    scanf("%d%d", &s, &c);
    if (vis[s] != -1 && vis[s] != c) {
      fg = 1;
    }
    if (s == 1 && c == 0 && !fg) {
      fg = 2;
    }
    vis[s] = c;
  }
  if (fg == 1) {
    cout << -1 << endl;
  } else if (fg == 2) {
    if (n == 1)
      cout << 0;
    else
      cout << -1;
  } else
    for (int i = 1; i <= n; i++) {
      if (i == 1 && !vis[i])
        cout << 1;
      else {
        if (vis[i] != -1)
          cout << vis[i];
        else
          cout << 0;
      }
    }
  return 0;
}
