#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> p[m];
  bool flag = false;
  char c[n + 1];
  for (int i = 0; i < n + 1; ++i) {
    c[i] = (i == 1) ? '1' : '0';
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i].first >> p[i].second;
    if (p[i].first == 1 && p[i].second == 0) flag = true;
  }
  if (flag) {
    cout << (-1) << "\n";
    return 0;
  }
  sort(p, p + m);
  for (int i = 0; i < m; ++i) {
    if (p[i].first == p[i + 1].first && p[i].second != p[i + 1].second)
      flag = true;
    else
      c[p[i].first] = '0' + p[i].second;
  }
  if (flag) {
    cout << (-1) << "\n";
    return 0;
  } else {
    for (int i = 1; i <= n; ++i) {
      printf("%c", c[i]);
    }
    printf("\n");
  }
}
