#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  int p = 0;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    if (a[x] != -1) {
      if (a[x] != y) {
        p = 1;
      }
    } else {
      a[x] = y;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      if (a[i] == 0) {
        p = 1;
      } else if (a[i] == -1) {
        a[i] = 1;
      }
    } else if (a[i] == -1)
      a[i] = 0;
  }
  if (p == 1)
    cout << -1 << '\n';
  else {
    for (auto x : a) cout << x;
  }
}
