#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, s, c;
  cin >> n >> m;
  vector<int> num(n, -1);
  bool ok = true;
  for (int i = int(0); i < int(m); ++i) {
    cin >> s >> c;
    s--;
    if (num[s] == -1)
      num[s] = c;
    else
      ok = ok && num[s] == c;
  }
  if (n > 1 && num[0] == 0) ok = false;
  if (!ok) {
    cout << -1 << endl;
    exit(0);
  }
  for (int i = int(0); i < int(n); ++i)
    if (num[i] == -1) num[i] = 1;
  for (int i = int(0); i < int(n); ++i) cout << num[i];
  cout << endl;
  return 0;
}
