#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> d(n + 1, -1);
  bool good = 1;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (d[s] != -1 and d[s] != c)
      good = 0;
    else
      d[s] = c;
  }
  for (int i = 1; i <= n; ++i) {
    if (d[i] == -1) {
      d[i] = i == 1 ? 1 : 0;
    }
  }
  if (d[1] == 0) good = 0;
  if (good)
    for (int i = 1; i <= n; ++i) cout << d[i];
  else
    cout << "-1";
  return 0;
}
