#include #include using namespace std; int main() { int n, m; cin >> n >> m; vector ans(n, 1); for (int i = 0; i < m; i++) { int p, q, a, b; cin >> p >> q >> a >> b; p--; q--; if (ans[p] != a && ans[q] != b) { cout << "-1\n"; return 0; } } for (int i = 0; i < n; i++) cout << ans[i] << (i == n - 1 ? '\n' : ' '); }