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