#include <cstdio>
#include <vector>
#include <map>
using namespace std;
#define N 8

int board[N][N];
vector< pair<int,int> > queen;
vector< pair<int,int> > sol_queen;

bool check(int k, int x, int y)
{
  for(int i=0;i<k;i++)
  {
    int tx = queen[i].first;
    int ty = queen[i].second;
    if(x == tx) return false;
    if(y == ty) return false;
    if((x-tx)*(x-tx) == (y-ty)*(y-ty)) return false;
  }
  return true;
}

/*
void printQueen() {
  for(int i=0;i<N;i++) {
    printf("%d : (%d,%d)\n",i,queen[i].first,queen[i].second);
  }
}
*/

void setQueen(int k,bool is_solution) {
  if(k == N && !is_solution) {
    is_solution = true;
    sol_queen = queen;
    return;
  }
  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(check(k,i,j)) {
        queen[k] = make_pair(i,j);
        setQueen(k+1,is_solution);
      }
    }
  }
}

int main() {
  // initialize
  queen.resize(N,make_pair(-1,-1));

  int k,r,c;
  scanf("%d",&k);
  for(int i=0;i<k;i++) {
    scanf("%d %d",&r,&c);
    queen[i] = make_pair(r,c);
  }

  setQueen(k,false);

  for(int k=0;k<N;k++) {
    board[sol_queen[k].first][sol_queen[k].second] = 1;
  }
  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(board[i][j] == 0)
        printf(".");
      else
        printf("Q");
    }
    printf("\n");
  }
}
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int A,B,C,D;
    vector<pair<int,int> > P;
    vector<int> R;

    cin >> N;

    P.push_back({1000000000,-1});
    R.resize(N+1);

    for(int i=1; i<=N; ++i) P.push_back({0,i});

    for(int i=0; i<N*(N-1)/2; ++i) {
        cin >> A >> B >> C >> D;
        if(C==D) {
            ++P[A].first;
            ++P[B].first;
        } else if(C>D) {
            P[A].first+=3;
        } else {
            P[B].first+=3;
        }
    }

    sort(P.rbegin(),P.rend());

    int rnk=1;

    R[P[1].second]=1;

    for(int i=2; i<=N; ++i) {
        if(P[i-1].first!=P[i].first) rnk=i;
        R[P[i].second]=rnk;
    }

    for(int i=1; i<=N; ++i) {
        cout << R[i] << endl;
    }

    return 0;
}