#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    int b = 1;
    for (int i = 0; i < m; i++) {
      int s, c;
      cin >> s >> c;
      if (s - 1 == 0 && c == 0) b = 0;
      if ((a[s - 1] == -1 || a[s - 1] == c) && c != 0)
        a[s - 1] = c;
      else
        b = 0;
    }
    if (a[0] == -1) a[0] = 1;
    if (b == 1) {
      for (int i = 1; i < n; i++)
        if (a[i] == -1) a[i] = 0;
      for (auto i : a) cout << i;
    } else
      cout << -1;
  }
}
