#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int maxn = 10005;
int a[maxn][maxn];
int dfs_vis[maxn];
int n, m;

struct Node
{
    int data;
} Point[maxn];

void DFS(int a[maxn][maxn], int x, int y)
{
    Point[x].data += y;
    dfs_vis[x] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (a[x][i] == 1 && dfs_vis[i] == 0)
        {
            DFS(a, i, y);
        }
    }
}
int main()
{
    cin >> n >> m;
    cin.get();

    for (int i = 1; i <= m; i++)
    {
        int flag, x1, x2;
        scanf("%d %d %d", &flag, &x1, &x2);
        if (flag == 1)
        {
            a[x1][x2] = a[x2][x1] = 1;
        }
        else if (flag == 2)
        {
            memset(dfs_vis, 0, sizeof(dfs_vis));
            DFS(a, x1, x2);
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        cout << Point[i].data << " ";
    }
    return 0;
}
