#include <bits/stdc++.h>
using namespace std;
bool ans = true;
int main() {
  int n, m;
  cin >> n >> m;
  string s = string(n, 'a');
  for (int i = 0; i < m; i++) {
    int pos, c;
    cin >> pos >> c;
    if (s[pos - 1] == 'a')
      s[pos - 1] = c + '0';
    else if (c + '0' != s[pos - 1])
      ans = false;
  }
  for (int i = 1; i < n; i++)
    if (s[i] == 'a') s[i] = '0';
  if (s[0] == '0')
    ans = false;
  else if (s[0] == 'a')
    s[0] = '1';
  if (ans) {
    cout << s << endl;
  } else
    cout << -1 << endl;
  return 0;
}
