#include <bits/stdc++.h>
using namespace std;
int n, m;
string str;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  str = string(n + 1, 'x');
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (str[s] == 'x')
      str[s] = '0' + c;
    else if (str[s] != '0' + c) {
      cout << "-1\n";
      return 0;
    }
  }
  int pos = false;
  for (int i = 1; i <= n; i++)
    if (!pos && str[i] == '0') {
      cout << "-1\n";
      return 0;
    } else if (str[i] != 'x' && str[i] != '0')
      pos = true;
    else if (pos && str[i] == 'x')
      str[i] = '0';
    else if (!pos && str[i] == 'x')
      str[i] = '1', pos = true;
  if (!pos)
    cout << "-1\n";
  else
    cout << str.substr(1) << "\n";
  return 0;
}
