#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, s, c, zero = '0';
  cin >> n >> m;
  bool impossible = false;
  string ans(n, '.');
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (ans[s - 1] != '.' and ans[s - 1] - '0' != c) {
      impossible = true;
    } else {
      ans[s - 1] = char('0' + c);
    }
  }
  if (impossible)
    cout << -1 << endl;
  else {
    for (int i = 0; i < ans.size(); i++) {
      if (ans[i] == '.') ans[i] = '1';
    }
    if (ans[0] != '0')
      cout << ans << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
