#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, -1);
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (ans[x] == -1) {
      ans[x] = y;
    } else {
      ok = false;
    }
  }
  if (ok) {
    for (int i = 2; i <= n; i++) {
      if (ans[i] == -1) {
        ans[i] = 0;
      }
    }
    if (ans[1] == -1) {
      if (n == 1) {
        ans[1] = 0;
      } else {
        ans[1] = 1;
      }
    } else if (ans[1] == 0) {
      if (n > 1) {
        ok = false;
      }
    }
    if (ok) {
      for (int i = 1; i <= n; i++) {
        cout << ans[i];
      }
    } else {
      cout << "-1";
    }
  } else {
    cout << "-1";
  }
}
