#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  bool t = true;
  int ans[n], num[n];
  for (int i = 0; i < n; i++) ans[i] = 0;
  if (m == 0) {
    cout << 1;
    for (int i = 0; i < n - 1; i++) cout << 0;
    cout << endl;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (num[a - 1] == 1 && ans[a - 1] != b) {
      cout << -1 << endl;
      t = false;
    }
    ans[a - 1] = b;
    num[a - 1] = 1;
    if (a == 1 && b == 0) {
      t = false;
      cout << -1 << endl;
    }
  }
  if (t) {
    for (int i = 0; i < n; i++) {
      if (num[i] == 0 && i == 0)
        ans[i] = 1;
      else if (num[i] == 0)
        ans[i] = 0;
      else
        continue;
    }
    for (int i = 0; i < n; i++) cout << ans[i];
    cout << endl;
  }
}
