#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k, ans, cur, res, i, j;
  cin >> n >> m;
  vector<long long> a(n, 10);
  for (i = 0; i < m; i++) {
    cin >> k >> cur;
    k--;
    if (a[k] == 10) {
      a[k] = cur;
    } else if (a[k] != cur) {
      cout << -1;
      return 0;
    }
  }
  if (n != 1 && a[0] == 0) {
    cout << -1;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (a[i] == 10 && i == 0) {
      cout << 1;
    } else if (a[i] == 10 && i != 0) {
      cout << 0;
    } else {
      cout << a[i];
    }
  }
  return 0;
}
