#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int a[5];
int second[7], c[7];
set<int> pos[4];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (!m) {
    if (n == 1)
      cout << 0;
    else if (n == 2)
      cout << 10;
    else if (n == 3)
      cout << 100;
    return 0;
  }
  for (int i = 1; i <= n; ++i) a[i] = 10;
  for (int i = 1; i <= m; ++i)
    cin >> second[i] >> c[i], pos[second[i]].insert(c[i]);
  for (int i = 1; i <= m; ++i)
    if (pos[c[i]].size() > 1) cout << -1, exit(0);
  for (int i = 1; i <= m; ++i) a[second[i]] = c[i];
  if (!a[1]) cout << -1, exit(0);
  if (a[1] == 10) a[1] = 1;
  for (int i = 2; i <= n; ++i)
    if (a[i] == 10) a[i] = 0;
  for (int i = 1; i <= n; ++i) cout << a[i];
  return 0;
}
