#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (n != 1 && s == 1 && c == 0) {
      cout << -1;
      return 0;
    }
    if (v[s - 1] == -1) v[s - 1] = c;
    if (v[s - 1] != c) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (v[i] == -1) {
      if (i)
        v[i] = 0;
      else
        v[i] = 1;
    }
    cout << v[i];
  }
  return 0;
}
