#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e16;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> s(m);
  vector<char> c(m);
  string res = "";
  for (long long i = 0; i < n; i++) res += 'x';
  bool flag = true;
  for (long long i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
    if (res[s[i]] == 'x')
      res[s[i]] = c[i];
    else if (res[s[i]] != c[i])
      flag = false;
  }
  if (res[0] == 'x') res[0] = '1';
  for (long long i = 1; i < n; i++)
    if (res[i] == 'x') res[i] = '0';
  if (!flag || (res[0] == '0' && res.size() != 1))
    cout << -1 << endl;
  else
    cout << res << endl;
}
