#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;
  int s[m + 5], c[m + 5];
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> c[i];
    indeks[s[i]] = c[i];
  }
  if (indeks[1] == 0 && n != 1) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cout << indeks[i];
  }
  cout << endl;
}
