import java.util.ArrayList;
import java.util.Scanner;
public class Main {
// setup
static ArrayList<cNode>[] F;
static long LCM;
static boolean[] visited;
static long[] D;
public static void main(String[] args) throws Exception {
// ISC - L1
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
// L2~
F = new ArrayList[N];
visited = new boolean[N];
D = new long[N];
LCM = 1;
for (int i = 0; i < N; i++) {
F[i] = new ArrayList<cNode>();
}
for (int i = 0; i < N; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
int p = sc.nextInt();
int q = sc.nextInt();
F[a].add(new cNode(b, p, q));
F[b].add(new cNode(a, q, p));
LCM *= (p * q / GCD(p, q));
}
// Operating DFS + plate
D[0] = LCM;
DFS(0);
long mgcd = D[0];
for (int i = 1; i < N; i++) {
mgcd = GCD(mgcd, D[i]);
}
// OEC
for (int i = 0; i < N; i++) {
System.out.print(D[i] / mgcd + " ");
}
}
// External Module : DFS
public static void DFS(int Node) {
visited[Node] = true;
for (cNode i : F[Node]) {
int next = i.getB();
if (!visited[next]) {
D[next] = D[Node] * i.getQ() / i.getP();
DFS(next);
}
}
}
// External Module : GCD
public static long GCD(long a, long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
}
// External Class
class cNode {
int b;
int p;
int q;
public cNode(int b, int p, int q) {
super();
this.b = b;
this.p = p;
this.q = q;
}
public int getB() {
return b;
}
public int getP() {
return p;
}
public int getQ() {
return q;
}
}