#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 9223372036854775807;
const long long mininf = -9223372036854775807;
const long long nax = 0;
int n, m;
unordered_map<int, int> indeks;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> m;
  if (m == 0) {
    for (int i = 1; i <= n; i++) {
      if (i == 1) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
    return 0;
  }
  int s[m + 5], c[m + 5];
  indeks[1] = 1;
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> c[i];
    if (indeks[s[i]] != 0) {
      indeks[s[i]] = min(c[i], indeks[s[i]]);
    } else {
      indeks[s[i]] = c[i];
    }
  }
  if (indeks[1] == 0 && n >= 2) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cout << indeks[i];
  }
  cout << endl;
}
