#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  unsigned n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  int s, c;
  bool flag = 0;
  for (unsigned i = 0; i < m; ++i) {
    cin >> s >> c;
    if (flag) continue;
    --s;
    if (a[s] == -1) {
      a[s] = c;
    } else {
      if (a[s] != c) {
        flag = 1;
      }
    }
    if (n > 1 && a[0] == 0) flag = 1;
  }
  if (flag)
    cout << "-1";
  else {
    for (auto &x : a) {
      if (x == -1) x = 0;
    }
    if (n > 1) {
      for (auto &x : a) {
        if (x == 0)
          x = 1;
        else
          break;
      }
    }
    for (auto x : a) cout << x;
  }
}
