#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define drep(i,b,a) for(int i = (b)-1; i >= (a); i--)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(v) sort(v.begin(),v.end());
#define RSORT(v) sort(v.rbegin(),v.rend());
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
const int inf = 1 << 30; const ll infl = 1LL << 60; const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool  odd(T x) { return x & 1; }
template<class T> inline bool even(T x) { return !(x & 1); }
template<typename A, size_t N, typename T> 
void Fill(A (&array)[N], const T &val) {
    std::fill( (T*)array, (T*)(array+N), val );
}
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << endl; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }
//----------------------------------------------------------------------------------------------

struct edge {
    int to;
    int c;
    edge(int to, int c):to(to),c(c){}
};
vector<edge> G[100010];
int res[100010];

void dfs(int v, int p = -1, int ok = 1) {
    if(ok) {
        if(p != -1) {
            if(res[p] != 0) res[v] = 0;
            else res[v] = 1;
        } else {
            res[v] = 0;
        }
        for(auto e : G[v]) {
            int nv = e.to;
            int co = e.c;
            if(res[nv] != -1) continue;
            if(co == res[v]) dfs(nv, v, ok);
            else {
                res[nv] = co;
                dfs(nv, v, 1-ok);
            }
        }
    }
    else {
        for(auto e : G[v]) {
            int nv = e.to;
            int co = e.c;
            if(res[nv] != -1) continue;
            if(co == res[v]) dfs(nv, v, 1-ok);
            else {
                res[nv] = co;
                dfs(nv, v, ok);
            }
        }
    }
}

int main() 
{
    int n,m;
    cin >> n >> m;
    rep(i,0,m) {
        int u,v,c;
        cin >> u >> v >> c;
        u--; v--; c--;
        G[u].emplace_back(v,c);
        G[v].emplace_back(u,c);
    }
    rep(i,0,n) res[i] = -1;
    dfs(0);
    rep(i,0,n) cout << res[i]+1 << endl;
    return 0;
}
// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i)
#define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--)
#define PII pair<int,int>
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define PQ priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<ll> VL;
typedef vector<vector<ll>> VLL;
constexpr int mod = 1e9 + 7;
constexpr int KINF = 0x3f3f3f3f;
constexpr int INF = 0x7f7f7f7f;
constexpr double eps = 1e-7;
int main(){
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	int r, x, y;
	cin >> r >> x >> y;
	ll dist = (1ll * x * x) + (1ll * y * y);
	//dist = ceil(sqrt(dist));
	if(dist < 1ll * r * r) {
		cout << 2 << endl;
		return 0;
	}
	ll k = 1;
	while(1ll * k * k * r * r < dist) k ++;
	cout << k << endl;
	return 0;
} 
// 小心左移运算符导致的int溢出
// dp记得处理非法状态
// resize并不会初始化数组
// 全局函数一定要记得inline
// 带空格字符串不能直接cin,要用getline
// 最好用用"\n"代替endl

