#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n);
  num[0] = 1;
  for (int i = 0; i < (n - 1); ++i) num.push_back(0);
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] != 0 && num[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    num[s] = c;
  }
  for (int i = 0; i < (n); ++i) cout << num[i];
  cout << endl;
  return 0;
}
