#include <bits/stdc++.h>
using namespace std;
const long long int N = 500010;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> ar(n, -1);
  int f = 1;
  for (int i = 0; i < m; ++i) {
    long long int idx, c;
    cin >> idx >> c;
    --idx;
    if (ar[idx] == -1) {
      ar[idx] = c;
    }
    if (ar[idx] != c) {
      f = 0;
    }
  }
  if (ar[0] == 0) {
    f = 0;
  }
  if (f == 0) {
    cout << "-1";
    return 0;
  }
  if (ar[0] == -1) {
    ar[0] = 1;
  }
  for (int i = 0; i < n; ++i) {
    if (ar[i] == -1) {
      ar[i] = 0;
    }
    cout << ar[i];
  }
  return (0);
}
