#include <bits/stdc++.h>
using namespace std;
inline void fastio() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long int INF = 1e10;
long long int MOD = 1e9 + 7;
long long int fast_power(long long int base, long long int power) {
  long long int result = 1;
  while (power > 0) {
    if (power % 2 == 1) result = (result * base) % MOD;
    base = (base * base) % MOD;
    power = power / 2;
  }
  return result;
}
int main() {
  fastio();
  int n, m;
  cin >> n >> m;
  vector<int> finale(n, -1);
  bool possi = 1;
  while (m--) {
    int i, c;
    cin >> i >> c;
    if (i == 1 && c == 0) {
      possi = 0;
      break;
    }
    if (finale[i - 1] != c && finale[i - 1] != -1) {
      possi = 0;
      break;
    }
    finale[i - 1] = c;
  }
  if (possi)
    for (auto x : finale) {
      if (x == -1)
        cout << 1;
      else
        cout << x;
    }
  else
    cout << -1;
  return 0;
}
