#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  bool f = false;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) {
      if (s[i] == s[j]) {
        if (c[i] != c[j]) f = true;
      }
    }
  for (int i = 0; i < m; i++)
    if (s[i] == 1 && c[i] == 0) f = true;
  if (f)
    cout << -1 << endl;
  else {
    string x = "0";
    for (int i = 0; i < m - 1; i++) x += "0";
    for (int i = 0; i < m; i++) x[s[i] - 1] = '0' + c[i];
    for (int i = 0; i < m; i++) {
      if (x[i] == '\0') {
        if (i == 0) x[i] == 1;
        if (i != 0) x[i] == 0;
      }
    }
    for (int i = 0; i < m; i++) cout << x[i];
    cout << endl;
  }
}
