#include <bits/stdc++.h>
using namespace std;
const int N = 100003;
int n, m, a[5][5];
bool st[5][5];
char s[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i += 1) s[i] = '+';
  for (int i = 1; i <= m; i += 1) {
    int u, v;
    cin >> u >> v;
    if (s[u] == '+')
      s[u] = v + '0';
    else if (s[u] != v + '0') {
      puts("-1");
      return 0;
    }
  }
  if (s[1] == '0') {
    puts("-1");
    return 0;
  }
  if (s[1] == '+') s[1] = '1';
  for (int i = 1; i <= n; i += 1)
    if (s[i] == '+')
      printf("0");
    else
      printf("%c", s[i]);
  puts("");
  return 0;
}
