#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  string st[m];
  for (int i = 0; i < m; ++i) st[i] = 'e';
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    st[--s] = '0' + c;
  }
  if (st[0] == "e" || st[0] == "0") {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    if (st[i] == "e") {
      st[i] = "0";
    }
  }
  for (int i = 0; i < m; ++i) {
    cout << st[i];
    if (i == m - 1) cout << endl;
  }
}
