#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 4;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  string s;
  for (int i = 0; i < n; i++) {
    s += '0';
  }
  vector<int> dd(m + 1);
  int flag = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1 && b[i] == 0) flag = 1;
    if (b[i] == 0) {
      if (!dd[a[i]])
        dd[a[i]] = -2;
      else
        flag = 1;
    }
    if (!dd[a[i]]) {
      dd[a[i]] = b[i];
    } else if (dd[a[i]] != b[i])
      flag = 1;
  }
  if (flag) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < m; i++) {
    s[a[i] - 1] = b[i] + '0';
  }
  if (s[0] == '0') s[0] = '1';
  cout << s;
  return 0;
}
