#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int n, m, s, c;
  cin >> n >> m;
  vll num(n, -1);
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (num[s] != -1 && num[s] != c) {
      cout << -1;
      return 0;
    }
    if (s == 0 && c == 0) {
      cout << -1;
      return 0;
    }
    num.at(s) = c;
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && num.size() == 1 && num[0] < 1) {
      cout << 0;
      return 0;
    }
    if (i == 0 && num.at(0) == -1)
      num.at(0) = 1;
    else if (num.at(i) == -1)
      num.at(i) = 0;
  }
  for (int i = 0; i < n; i++) cout << num.at(i);
  return 0;
}
