#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string str = to_string((int)pow(10, n - 1));
  string mask = str;
  mask[0] = 0;
  int m;
  cin >> m;
  vector<int> mem(n, -1);
  while (m--) {
    int s;
    int c;
    cin >> s >> c;
    if (mem[s - 1] != -1 && mem[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    str[s - 1] = '0' + c;
    mem[s - 1] = c;
  }
  if (str == mask && n >= 2)
    cout << -1 << endl;
  else
    cout << str << endl;
  return 0;
}
