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