#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> digits(n, -1);
  bool works = true;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (digits[s - 1] != -1 && digits[s - 1] != c || s == 1 && c == 0)
      works = false;
    else
      digits[s - 1] = c;
  }
  if (!works) {
    cout << "-1\n";
    exit(0);
  }
  if (digits[0] == -1) digits[0] = 1;
  for (int i = 1; i < n; ++i)
    if (digits[i] == -1) digits[i] = 0;
  for (int u : digits) cout << u;
}
