#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> res(n, -1);
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << (-1) << "\n";
      return 0;
    }
    if (res[s] == -1) {
      res[s] = c;
    } else {
      if (res[s] != c) {
        cout << (-1) << "\n";
        return 0;
      }
    }
  }
  for (int i = 0; i < (n); ++i) {
    if (res[i] == -1) {
      if (i == 0)
        res[i] = 1;
      else
        res[i] = 0;
    }
  }
  for (int i = 0; i < (n); ++i) cout << res[i];
  cout << endl;
  return 0;
}
