#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9 + 7;
const int mod = 1e9 + 7;
int a[5], s, c, flag = 0;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(a, -1, sizeof(a));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (a[s - 1] == -1) {
      a[s - 1] = c;
    } else if (a[s - 1] != c) {
      flag = 1;
    }
  }
  if (flag || a[0] == 0 && n != 1)
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      if (i == 0 && a[i] == -1)
        cout << 1;
      else if (a[i] == -1)
        cout << 0;
      else
        cout << a[i];
    }
  }
}
