#include <bits/stdc++.h>
using namespace std;
int s[3] = {-1, -1, -1};
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ind, x;
    cin >> ind >> x;
    ind--;
    if (s[ind] != -1 && s[ind] != x) {
      cout << -1;
      return;
    }
    s[ind] = x;
  }
  if (s[0] == 0) {
    cout << -1;
    return;
  }
  for (int i = 0; i < n; i++) {
    int t = 0 + (i == 0);
    if (s[i] == -1) {
      s[i] = t;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
}
int main() { solve(); }
