#include <bits/stdc++.h>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
void solve() {
  int n, m;
  cin >> n >> m;
  string res(n, '$');
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (res[s - 1] != '$' && res[s - 1] != (c + '0')) {
      cout << "-1\n";
      return;
    }
    res[s - 1] = (c + '0');
  }
  if (res[0] == '0') {
    cout << "-1\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    if (res[i] == '$') {
      if (i == 0)
        res[0] = '1';
      else
        res[i] = '0';
    }
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
