#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  string s = string(n, 'c');
  while (m--) {
    int x, c;
    cin >> x >> c;
    x--;
    char tp = (char)c + '0';
    if (s[x] != 'c' && s[x] != tp) {
      cout << "-1\n";
      return 0;
    }
    s[x] = tp;
  }
  bool l = false;
  for (int i = 0; i < n; ++i) {
    if (i) {
      if (s[i] == 'c') s[i] = '0';
    } else {
      if (s[i] == '0') {
        cout << "-1\n";
        return 0;
      }
      if (s[i] == 'c') s[i] = '1';
    }
  }
  cout << s << endl;
}
