#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  while (m--) {
    int i, v;
    cin >> i >> v;
    i = i - 1;
    if (a[i] != -1 and a[i] != v) {
      cout << -1;
      return 0;
    } else {
      a[i] = v;
    }
  }
  if (a[0] == 0) {
    cout << -1;
    return 0;
  } else if (a[0] == -1) {
    a[0] = 1;
  }
  for (int x : a) {
    if (x == -1) x = 0;
    cout << x;
  }
}
