#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int d[n];
  for (int i = 0; i < n; i++) {
    d[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (d[s - 1] != -1 && d[s - 1] != c) {
      cout << "-1" << endl;
      return 0;
    } else {
      d[s - 1] = c;
    }
  }
  if (m == 0) {
    if (n == 1)
      cout << "0" << endl;
    else if (n == 2)
      cout << "10" << endl;
    else
      cout << "100" << endl;
    return 0;
  }
  if (n != 1 && (d[0] == 0 || d[0] == -1)) {
    cout << "-1" << endl;
  } else {
    cout << d[0];
    for (int i = 1; i < n; i++) {
      if (d[i] == -1)
        cout << "0";
      else
        cout << d[i];
    }
    cout << endl;
  }
  return 0;
}
