#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int s[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  int a[n];
  memset(a, -1, sizeof(a));
  bool p = true;
  for (int i = 0; i < m; i++) {
    int temp = c[i];
    if (a[s[i]] == -1) {
      if (temp == 0 && s[i] == 0) {
        p = false;
        break;
      } else {
        a[s[i]] = temp;
      }
    } else {
      if (a[s[i]] != temp) {
        p = false;
        break;
      } else {
        continue;
      }
    }
  }
  if (p == false) {
    cout << -1;
  } else {
    if (n == 1) {
      if (a[0] == -1) {
        a[0] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) {
        if (i == 0) {
          a[i] = 1;
        } else {
          a[i] = 0;
        }
      }
      cout << a[i];
    }
  }
  return 0;
}
