#include <bits/stdc++.h>
using namespace std;
long long int hell = pow(10, 9) + 7;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) arr[i] = 1;
  vector<pair<long long int, long long int> > v;
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    if (x > n) {
      cout << "-1";
      return;
    }
    arr[x - 1] = y;
    v.push_back({x, y});
  }
  for (long long int i = 0; i < m; i++)
    if (arr[v[i].first - 1] != v[i].second) {
      cout << "-1";
      return;
    }
  if (arr[0] == 0) {
    cout << "-1";
    return;
  }
  for (long long int i = 0; i < n; i++) cout << arr[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  for (long long int qc = 0; qc < t; qc++) solve();
}
