#include <iostream>

using namespace std;

int main() {

  char mark;
  int card[4][13];
  int i, j, n, num;

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> mark >> num;
    switch (mark) {
    case 'S':
      card[0][num] = 1;
      break;
    case 'H':
      card[1][num] = 1;
      break;
    case 'C':
      card[2][num] = 1;
      break;
    case 'D':
      card[3][num] = 1;
      break;
    }
  }

  cout << endl;

  for (i = 0; i < 4; i++) {
    for (j = 1; j < 14; j++) {
      if (card[i][j] != 1) {

        if (i == 0) {
          cout << "S " << j << endl;
        }
        if (i == 1) {
          cout << "H " << j << endl;
        }
        if (i == 2) {
          cout << "C " << j << endl;
        }
        if (i == 3) {
          cout << "D " << j << endl;
        }
      }
    }
  }
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n;

  bool l[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      l[i][j] = false;
    }
  }

  cin >> n;

  for (int i = 0; i < n; i++) {
    char mark;
    int number;
    cin >> mark >> number;
    switch (mark) {
    case 'S':
      l[0][number - 1] = true;
      break;
    case 'H':
      l[1][number - 1] = true;
      break;
    case 'C':
      l[2][number - 1] = true;
      break;
    case 'D':
      l[3][number - 1] = true;
      break;
    }
  }

  // 0:S
  for (int j = 0; j < 13; j++) {
    if (l[0][j] == false) {
      cout << "S " << j + 1 << endl;
    }
  }

  // 1:H
  for (int j = 0; j < 13; j++) {
    if (l[1][j] == false) {
      cout << "H " << j + 1 << endl;
    }
  }

  // 2:C
  for (int j = 0; j < 13; j++) {
    if (l[2][j] == false) {
      cout << "C " << j + 1 << endl;
    }
  }

  // 3:D
  for (int j = 0; j < 13; j++) {
    if (l[3][j] == false) {
      cout << "D " << j + 1 << endl;
    }
  }

  return (0);
}


*** stack smashing detected ***: terminated


#include <iostream>
#include <string>

using namespace std;

int main() {
  int cards[4][13];
  int x, n;
  string a;

  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> a >> x;
    if (a == "S") {
      cards[0][x] = 1;
    } else if (a == "H") {
      cards[1][x] = 1;
    } else if (a == "C") {
      cards[2][x] = 1;
    } else if (a == "D") {
      cards[3][x] = 1;
    }
  }

  for (int j = 1; j <= 13; j++) {
    if (cards[0][j] != 1) {
      cout << "S"
           << " " << j << endl;
    }
    if (cards[1][j] != 1) {
      cout << "H"
           << " " << j << endl;
    }
    if (cards[2][j] != 1) {
      cout << "C"
           << " " << j << endl;
    }
    if (cards[3][j] != 1) {
      cout << "D"
           << " " << j << endl;
    }
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  bool cards[4][13];
  int n, rank;
  char suit;

  for (int s = 0; s < 4; s++)
    for (int r = 0; r < 13; r++)
      cards[s][r] = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> suit >> rank;
    if (suit == 'S')
      cards[0][rank] = 1;
    if (suit == 'H')
      cards[1][rank] = 1;
    if (suit == 'C')
      cards[2][rank] = 1;
    if (suit == 'D')
      cards[3][rank] = 1;
  }

  for (int s = 0; s < 4; s++) {
    for (int r = 0; r <= 13; r++) {
      if (cards[s][r])
        continue;
      if (s == 0)
        suit = 'S';
      if (s == 1)
        suit = 'H';
      if (s == 2)
        suit = 'C';
      if (s == 3)
        suit = 'D';
      cout << suit << " " << r << endl;
    }
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  bool cards[4][14];
  int n, rank;
  char suit;

  for (int s = 0; s < 4; s++)
    for (int r = 1; r <= 13; r++)
      cards[s][r] = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> suit >> rank;
    if (suit == 'S')
      cards[0][rank] = 1;
    if (suit == 'H')
      cards[1][rank] = 1;
    if (suit == 'C')
      cards[2][rank] = 1;
    if (suit == 'D')
      cards[3][rank] = 1;
  }

  for (int s = 0; s < 4; s++) {
    for (int r = 1; r <= 13; r++) {
      if (cards[s][r])
        continue;
      if (s == 0)
        suit = 'S';
      if (s == 1)
        suit = 'H';
      if (s == 2)
        suit = 'C';
      if (s == 3)
        suit = 'D';
      cout << suit << " " << r << endl;
    }
  }

  return 0;
}


#include <algorithm>
#include <iostream>

using namespace std;

int main() {

  int n;

  bool S[13], H[13], C[13], D[13];
  fill(S, S + 13, false);
  fill(H, H + 13, false);
  fill(C, C + 13, false);
  fill(D, D + 13, false);

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    char a;
    int b;

    std::cin >> a >> b;

    switch (a) {
    case 'S':
      S[b - 1] = true;
      break;
    case 'H':
      H[b - 1] = true;
      break;
    case 'C':
      C[b - 1] = true;
      break;
    case 'D':
      D[b - 1] = true;
      break;
    }
  }

  // std::cout << "XXXXXXXXXXXXXXXXXXXXX\\n";

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      switch (i) {
      case 0:
        if (S[j] == false) {
          std::cout << "S " << j + 1 << endl;
        }
        break;
      case 1:
        if (H[j] == false) {
          std::cout << "H " << j + 1 << endl;
        }
        break;
      case 2:
        if (C[j] == false) {
          std::cout << "C " << j + 1 << endl;
        }
        break;
      case 3:
        if (D[j] == false) {
          std::cout << "D " << j + 1 << endl;
        }
        break;
      }
    }
  }

  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
  int i, n, num;
  int Scard[14] = {0}, Hcard[14] = {0}, Ccard[14] = {0}, Dcard[14] = {0};
  char mark = '0';

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %d", mark, &num);
    if (mark == 'S') {
      Scard[num] = 1;
    } else if (mark == 'H') {
      Hcard[num] = 1;
    } else if (mark == 'C') {
      Ccard[num] = 1;
    } else if (mark == 'D') {
      Dcard[num] = 1;
    }
  }

  for (i = 1; i <= 13; i++) {
    if (Scard[i] != 1) {
      printf("S %d", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Hcard[i] != 1) {
      printf("H %d", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Ccard[i] != 1) {
      printf("C %d", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Dcard[i] != 1) {
      printf("D %d", i);
    }
  }

  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
  int i, j, n, num;
  int Scard[14] = {0}, Hcard[14] = {0}, Ccard[14] = {0}, Dcard[14] = {0};
  char mark = '0';

  scanf("%d", &n);
  getchar();

  for (j = 0; j < n; j++) {

    scanf("%c %d", &mark, &num);
    getchar();

    if (mark == 'S') {
      Scard[num] = 1;
    } else if (mark == 'H') {
      Hcard[num] = 1;
    } else if (mark == 'C') {
      Ccard[num] = 1;
    } else if (mark == 'D') {
      Dcard[num] = 1;
    }
  }

  for (i = 1; i <= 13; i++) {
    if (Scard[i] == 0) {
      printf("S %d\\n", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Hcard[i] == 0) {
      printf("H %d\\n", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Ccard[i] == 0) {
      printf("C %d\\n", i);
    }
  }
  for (i = 1; i <= 13; i++) {
    if (Dcard[i] == 0) {
      printf("D %d\\n", i);
    }
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  bool cards[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      cards[i][j] = 1;
    }
  }

  int n, rank;
  char mark;
  cin >> n;

  for (int x = 1; x <= n; x++) {
    cin >> mark >> rank;

    if (mark == 'S') {
      cards[0][rank] = 0;
    }
    if (mark == 'H') {
      cards[1][rank] = 0;
    }
    if (mark == 'C') {
      cards[2][rank] = 0;
    }
    if (mark == 'D') {
      cards[3][rank] = 0;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (cards[i][j] == 0) {
        continue;
      }

      if (i == 0)
        mark = 'S';
      if (i == 1)
        mark = 'H';
      if (i == 2)
        mark = 'C';
      if (i == 3)
        mark = 'D';

      cout << mark << " " << j << endl;
    }
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int cards[4][14];
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      cards[i][j] = 1;
    }
  }

  int n, rank;
  char mark;
  cin >> n;

  for (int x = 1; x <= n; x++) {
    cin >> mark >> rank;

    if (mark == 'S') {
      cards[0][rank] = 0;
    }
    if (mark == 'H') {
      cards[1][rank] = 0;
    }
    if (mark == 'C') {
      cards[2][rank] = 0;
    }
    if (mark == 'D') {
      cards[3][rank] = 0;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (cards[i][j] == 0) {
        continue;
      }

      if (i == 0)
        mark = 'S';
      if (i == 1)
        mark = 'H';
      if (i == 2)
        mark = 'C';
      if (i == 3)
        mark = 'D';

      cout << mark << " " << j << endl;
    }
  }

  return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main(void) {
  int n, r;
  int a[4][13];
  string rank;

  // 配列初期化
  for (int i = 0; i < 4; i++) {
    for (int j = 0; i < 13; i++) {
      a[i][j] = 0;
    }
  }
  cin >> n;
  for (int m = 0; m < n; m++) {
    cin >> rank >> n;
    if (rank == "S") {
      r = 0;
    } else if (rank == "H") {
      r = 1;
    } else if (rank == "C") {
      r = 2;
    } else if (rank == "D") {
      r = 3;
    }

    a[r][n] = 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (a[i][j] != 1) {
        if (i == 0) {
          rank == "S";
        }
        if (i == 1) {
          rank == "H";
        }
        if (i == 0) {
          rank == "C";
        }
        if (i == 0) {
          rank == "D";
        }
        cout << rank << " " << j << endl;
      }
    }
  }
  return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main(void) {
  int n, r, number;
  int a[4][13];
  char R;

  // 配列初期化
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      a[i][j] = 0;
    }
  }
  cin >> n;
  for (int m = 0; m < n; m++) {
    cin >> R >> number;
    if (R == 'S') {
      r = 0;
    } else if (R == 'H') {
      r = 1;
    } else if (R == 'C') {
      r = 2;
    } else if (R == 'D') {
      r = 3;
    }

    a[r][number - 1] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (a[i][j] != 1) {
        if (i == 0)
          R = 'S';
        if (i == 1)
          R = 'H';
        if (i == 2)
          R = 'C';
        if (i == 3)
          R = 'D';
        cout << R << " " << j + 1 << endl;
      }
    }
  }
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#define MAX 1000
#define rep(i, a) for (i = 1; i <= a; i++)
using namespace std;
typedef pair<char, int> p;
int main(void) {
  int n, i, j;
  p card[53];
  int s[13], h[13], c[13], d[13];
  rep(i, 13) {
    s[i] = MAX;
    h[i] = MAX;
    c[i] = MAX;
    d[i] = MAX;
  }
  cin >> n;
  rep(i, n) cin >> card[i].first >> card[i].second;
  rep(i, n) {
    if (card[i].first == 'S')
      s[card[i].second] = card[i].second;
    else if (card[i].first == 'H')
      h[card[i].second] = card[i].second;
    else if (card[i].first == 'C')
      c[card[i].second] = card[i].second;
    else
      d[card[i].second] = card[i].second;
  }
  rep(i, 13) if (s[i] == MAX) cout << "S " << i << endl;
  rep(i, 13) if (h[i] == MAX) cout << "H " << i << endl;
  rep(i, 13) if (c[i] == MAX) cout << "C " << i << endl;
  rep(i, 13) if (d[i] == MAX) cout << "D " << i << endl;
  return 0;
}

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#define MAX 1000
#define TS 13
#define rep(i, a) for (i = 1; i <= a; i++)
using namespace std;
typedef pair<char, int> p;
int main(void) {
  int n, i, j;
  p card[53];
  int s[TS + 1], h[TS + 1], c[TS + 1], d[TS + 1];
  rep(i, TS) {
    s[i] = MAX;
    h[i] = MAX;
    c[i] = MAX;
    d[i] = MAX;
  }
  cin >> n;
  rep(i, n) cin >> card[i].first >> card[i].second;
  rep(i, n) {
    if (card[i].first == 'S')
      s[card[i].second] = card[i].second;
    else if (card[i].first == 'H')
      h[card[i].second] = card[i].second;
    else if (card[i].first == 'C')
      c[card[i].second] = card[i].second;
    else
      d[card[i].second] = card[i].second;
  }
  rep(i, TS) if (s[i] == MAX) cout << "S " << i << endl;
  rep(i, TS) if (h[i] == MAX) cout << "H " << i << endl;
  rep(i, TS) if (c[i] == MAX) cout << "C " << i << endl;
  rep(i, TS) if (d[i] == MAX) cout << "D " << i << endl;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  bool x[4][13] = {0};
  int number, n, i, j;
  char mark;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> mark >> number;
    if (mark == 'S') {
      x[0][number] = 1;
    } else if (mark == 'H') {
      x[1][number] = 1;
    } else if (mark == 'C') {
      x[2][number] = 1;
    } else if (mark == 'D') {
      x[3][number] = 1;
    }
  }
  for (j = 0; j < 4; j++) {
    for (i = 1; i <= 13; i++) {

      if (x[j][i] == 0) {
        if (j == 0) {
          cout << "S " << i << endl;
        } else if (j == 1) {
          cout << "H " << i << endl;
        } else if (j == 2) {
          cout << "C " << i << endl;
        } else if (j == 3) {
          cout << "D " << i << endl;
        }
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  bool card[3][12] = {false};
  int n, o, p;
  string x;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> o;
    if (x == "S") {
      card[0][o - 1] = true;
    } else if (x == "H") {
      card[1][o - 1] = true;
    } else if (x == "C") {
      card[2][o - 1] = true;
    } else if (x == "D") {
      card[3][o - 1] = true;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == false) {
        if (i == 0) {
          cout << "S " << j + 1 << endl;
        } else if (i == 1) {
          cout << "H " << j + 1 << endl;
        } else if (i == 2) {
          cout << "C " << j + 1 << endl;
        } else if (i == 3) {
          cout << "D " << j + 1 << endl;
        }
      }
    }
  }
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  bool card[4][13] = {false};
  int n, o, p;
  string x;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> o;
    if (x == "S") {
      card[0][o - 1] = true;
    } else if (x == "H") {
      card[1][o - 1] = true;
    } else if (x == "C") {
      card[2][o - 1] = true;
    } else if (x == "D") {
      card[3][o - 1] = true;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == false) {
        if (i == 0) {
          cout << "S " << j + 1 << endl;
        } else if (i == 1) {
          cout << "H " << j + 1 << endl;
        } else if (i == 2) {
          cout << "C " << j + 1 << endl;
        } else if (i == 3) {
          cout << "D " << j + 1 << endl;
        }
      }
    }
  }
}


#include <iostream>
using namespace std;
int main() {
  char ch;
  int n, m;
  bool ArrS[13], ArrC[13], ArrD[13], ArrH[13];
  for (int i = 1; i <= 13; i++) {
    ArrS[i] != false;
    ArrH[i] != false;
    ArrD[i] != false;
    ArrC[i] != false;
  }
  cin >> m;
  while (m-- > 0) {
    cin >> ch >> n;
    switch (ch) {
    case 'S':
      ArrS[n] = true;
      break;
    case 'C':
      ArrC[n] = true;
      break;
    case 'D':
      ArrD[n] = true;
      break;
    case 'H':
      ArrH[n] = true;
      break;
    }
  }
  for (int i = 1; i <= 13; i++) {
    if (ArrS[i] != true)
      cout << "S " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (ArrH[i] != true)
      cout << "H " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (ArrC[i] != true)
      cout << "C " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (ArrD[i] != true)
      cout << "D " << i << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  char ch;
  int n, m;
  bool ar[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++)
      ar[i][j] = false;
  }
  cin >> m;
  while (m-- > 0) {
    cin >> ch >> n;
    switch (ch) {
    case 'S':
      ar[0][n - 1] = true;
      break;
    case 'C':
      ar[2][n - 1] = true;
      break;
    case 'D':
      ar[3][n - 1] = true;
      break;
    case 'H':
      ar[1][n - 1] = true;
      break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++)
      if (ar[i][j] == false) {
        if (i == 0)
          cout << "S ";
        else if (i == 1)
          cout << "H ";
        else if (i == 2)
          cout << "C ";
        else
          cout << "D ";
        cout << j + 1 << endl;
        ;
      }
  }
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, x;
  int card[4][13] = {{}};
  cin >> n;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 14; j++) {
      card[i][j] = false;
    }
  }
  char y;
  for (int i = 0; i < n; i++) {
    cin >> y >> x;
    if (y == 'S') {
      card[0][x - 1] = true;
    } else if (y == 'H') {
      card[1][x - 1] = true;
    } else if (y == 'C') {
      card[2][x - 1] = true;
    } else if (y == 'D') {
      card[3][x - 1] = true;
    }
  }
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 14; j++) {
      if (card[i][j] != 1) {
        if (i == 0) {
          cout << 'S' << " " << j << endl;
        } else if (i == 1) {
          cout << 'H' << " " << j << endl;
        } else if (i == 2) {
          cout << 'C' << " " << j << endl;
        } else if (i == 3) {
          cout << 'D' << " " << j << endl;
        }
      }
    }
  }
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  cin >> n;
  int card[4][14];

  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    int c;
    if (a == 'S')
      c = 0;
    else if (a == 'H')
      c = 1;
    else if (a == 'C')
      c = 2;
    else
      c = 3;
    card[a][c] = true;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; i < 14; i++) {
      char c;
      if (i == 0)
        c = 'S';
      else if (i == 1)
        c = 'H';
      else if (i == 2)
        c = 'C';
      else
        c = 'D';
      if (card[i][j] == true)
        continue;
      else
        cout << c << ' ' << j << endl;
    }
  }

  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int n, b;
  char a;
  cin >> n;
  int card[4][14];
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      card[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == 'S')
      card[0][b] = 1;
    else if (a == 'H')
      card[1][b] = 1;
    else if (a == 'C')
      card[2][b] = 1;
    else
      card[3][b] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      char d;
      if (card[i][j])
        continue;
      if (i == 0)
        d = 'S';
      else if (i == 1)
        d = 'H';
      else if (i == 2)
        d = 'C';
      else
        d = 'D';
      cout << d << ' ' << j << endl;
    }
  }

  return 0;
}

S 1
H 1
C 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1
D 1


// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_B
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, buf_n;
  cin >> n;
  string S = "S", H = "H", C = "C", D = "D";
  string buf_s;

  int cards[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      cards[i][j] = 0; //????????\\??£???????????¶???????????¨???
    }
  }

  for (int i = 0; i < n; i++) {
    cin >> buf_s >> buf_n;
    if (buf_s == S) {
      cards[0][buf_n] = 1;
    }
    if (buf_s == H) {
      cards[1][buf_n] = 1;
    }
    if (buf_s == C) {
      cards[2][buf_n] = 1;
    }
    if (buf_s == D) {
      cards[3][buf_n] = 1;
    }
  }

  for (int j = 1; j < 14; j++) {
    if (cards[0][j] == 0) {
      cout << S << " " << j << endl;
    }
  }
  for (int j = 1; j < 14; j++) {
    if (cards[1][j] == 0) {
      cout << H << " " << j << endl;
    }
  }
  for (int j = 1; j < 14; j++) {
    if (cards[2][j] == 0) {
      cout << C << " " << j << endl;
    }
  }
  for (int j = 1; j < 14; j++) {
    if (cards[3][j] == 0) {
      cout << D << " " << j << endl;
    }
  }
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int n;
  int set[52] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    char suit;
    int rank;
    cin >> suit >> rank;
    int suit2Num;
    switch (suit2Num) {
    case 'S':
      suit2Num = 0;
      break;
    case 'H':
      suit2Num = 1;
      break;
    case 'C':
      suit2Num = 2;
      break;
    case 'D':
      suit2Num = 3;
      break;
    default:
      break;
    }
    set[13 * suit2Num + (rank - 1)] = 1;
  }
  char num2Suit[4] = {'S', 'H', 'C', 'D'};
  for (int i = 0; i < n; i++) {
    if (set[i]) {
      char suitAns = i / 13;
      int rankAns = i % 13 + 1;
      cout << suitAns << " " << rankAns << endl;
    }
  }
  return 0;
}

#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int n;
  int set[52] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    char suit;
    int rank;
    cin >> suit >> rank;
    int suit2Num;
    switch (suit) {
    case 'S':
      suit2Num = 0;
      break;
    case 'H':
      suit2Num = 1;
      break;
    case 'C':
      suit2Num = 2;
      break;
    case 'D':
      suit2Num = 3;
      break;
    default:
      break;
    }
    set[13 * suit2Num + (rank - 1)] = 1;
  }
  char num2Suit[4] = {'S', 'H', 'C', 'D'};
  for (int i = 0; i < 52; i++) {
    if (!set[i]) {
      char suitAns = num2Suit[i / 13];
      int rankAns = i % 13 + 1;
      cout << suitAns << " " << rankAns << endl;
    }
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, x;
  char mark;
  bool cards[4][14];

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 13; j++) {
      cards[i][j] = 0;
    }
  }

  cin >> n;
  for (int k = 1; k <= n; k++) {
    cin >> mark >> x;
    if (mark == 'S')
      cards[1][x] = 1;
    else if (mark == 'H')
      cards[2][x] = 1;
    else if (mark == 'C')
      cards[3][x] = 1;
    else if (mark == 'D')
      cards[4][x] = 1;
  }

  for (int s = 1; s <= 4; s++) {
    for (int t = 1; t <= 13; t++) {
      if (cards[s][t])
        continue;
      else if (s == 1)
        mark == 'S';
      else if (s == 2)
        mark == 'H';
      else if (s == 3)
        mark == 'C';
      else if (s == 4)
        mark == 'D';

      cout << mark << " " << t << endl;
    }
  }

  return 0;
}


#include <stdio.h>

int main() {
  char cd;
  int i, j, n, rank;
  int card[4][13];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      card[i][j] = 0;
    }
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%c %d", &cd, &rank);
    switch (cd) {
    case 'S':
      card[0][rank - 1] = 1;
      break;

    case 'H':
      card[1][rank - 1] = 1;
      break;

    case 'C':
      card[2][rank - 1] = 1;
      break;

    case 'D':
      card[3][rank - 1] = 1;
      break;
    }

    for (i = 0; i < 4; i++) {
      for (j = 0; j < 13; j++) {
        if (card[i][j] == 0) {
          switch (i) {
          case 0:
            printf("S %d\\n", j + 1);
            break;

          case 1:
            printf("H %d\\n", j + 1);
            break;

          case 2:
            printf("C %d\\n", j + 1);
            break;

          case 3:
            printf("D %d\\n", j + 1);
            break;
          }
        }
      }
    }
  }
  printf("\\n");
}

#include <stdio.h>

int main() {
  char cd;
  int i, j, n, rank;
  int card[4][13];
  char buf[512];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      card[i][j] = 0;
    }
  }
  fgets(buf, 512, stdin);
  sscanf(buf, "%d", &n);
  for (i = 0; i < n; i++) {
    fgets(buf, 512, stdin);
    sscanf(buf, "%c %d", &cd, &rank);
    switch (cd) {
    case 'S':
      card[0][rank - 1] = 1;
      break;

    case 'H':
      card[1][rank - 1] = 1;
      break;

    case 'C':
      card[2][rank - 1] = 1;
      break;

    case 'D':
      card[3][rank - 1] = 1;
      break;
    }
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          printf("S %d\\n", j + 1);
          break;

        case 1:
          printf("H %d\\n", j + 1);
          break;

        case 2:
          printf("C %d\\n", j + 1);
          break;

        case 3:
          printf("D %d\\n", j + 1);
          break;
        }
      }
    }
  }
  return 0;
}


#include <cstdio>
using namespace std;
int main(void) {
  // Here your code !
  bool cards[4][13];
  int num, existing;
  char mark;

  scanf("%d", &existing);
  for (int i = 0; i < existing; i++) {
    scanf("%c", &mark);
    if (mark == 'S') {
      scanf("%d", &num);
      cards[0][num - 1] = true;
    } else if (mark == 'H') {
      scanf("%d", &num);
      cards[1][num - 1] = true;
    } else if (mark == 'C') {
      scanf("%d", &num);
      cards[2][num - 1] = true;
    } else {
      scanf("%d", &num);
      cards[3][num - 1] = true;
    }

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 13; j++) {
        if (cards[i][j] == false) {
          if (i == 0) {
            printf("%c %d\\n", 'S', j + 1);
          }
          if (i == 1) {
            printf("%c %d\\n", 'H', j + 1);
          }
          if (i == 2) {
            printf("%c %d\\n", 'C', j + 1);
          }
          if (i == 3) {
            printf("%c %d\\n", 'D', j + 1);
          }
        }
      }
    }
  }
  return 0;
}

#include <cstdio>
int main() {
  int cards[4][13] = {0};
  int num, existing;
  char mark;
  int i, j;

  scanf("%d", &existing);
  for (i = 0; i < existing; i++) {
    scanf(" %c %d", &mark, &num);
    if (mark == 'S') {
      cards[0][num - 1] = 1;
    } else if (mark == 'H') {
      cards[1][num - 1] = 1;
    } else if (mark == 'C') {
      cards[2][num - 1] = 1;
    } else if (mark == 'D') {
      cards[3][num - 1] = 1;
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (cards[i][j] == 0) {
        if (i == 0) {
          printf("S %d\\n", j + 1);
        } else if (i == 1) {
          printf("H %d\\n", j + 1);
        } else if (i == 2) {
          printf("C %d\\n", j + 1);
        } else if (i == 3) {
          printf("D %d\\n", j + 1);
        }
      }
    }
  }
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, a, YJSNPI[4][13];
  char c;
  cin >> n;
  for (int i = 0; i <= n; i++) {

    cin >> c >> a;
    if (c == 'S')
      YJSNPI[0][a] = a;
    else if (c == 'H')
      YJSNPI[1][a] = a;
    else if (c == 'C')
      YJSNPI[2][a] = a;
    else if (c == 'D')
      YJSNPI[3][a] = a;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[2][1] != i)
      cout << 'C' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;
int main(void) {
  int n, a, YJSNPI[10][100];
  char ch;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S')
      YJSNPI[0][a] = a;
    else if (ch == 'H')
      YJSNPI[1][a] = a;
    else if (ch == 'C')
      YJSNPI[2][a] = a;
    else if (ch == 'D')
      YJSNPI[3][a] = a;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[2][i] != i)
      cout << 'C' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;
int main(void) {
  int n, a, YJSNPI[4][13];
  char ch;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S')
      YJSNPI[0][a];
    else if (ch == 'H')
      YJSNPI[1][a];
    else if (ch == 'C')
      YJSNPI[2][a];
    else if (ch == 'D')
      YJSNPI[3][a];
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
    if (YJSNPI[2][i] != i)
      cout << 'C' << " " << i << endl;
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}


#include <iomanip>
#include <iostream>
using namespace std;

int main() {
  int n;
  int card[4][14] = {};
  cin >> n;
  for (int i = 0; i, n; i++) {
    char suit;
    int num;
    int suitn;
    cin >> suit >> num;
    switch (suit) {
    case 'S':
      suitn = 0;
      break;
    case 'H':
      suitn = 1;
      break;
    case 'C':
      suitn = 2;
      break;
    case 'D':
      suitn = 3;
      break;
    }
    card[suitn][num] = 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      char suitc[4] = {
          'S',
          'H',
          'C',
          'D',
      };
      if (card[i][j] == 0) {
        cout << suitc[i] << ' ' << j << endl;
      }
    }
  }
  return 0;
}

#include <iomanip>
#include <iostream>
using namespace std;

int main() {
  int n;
  int card[4][14] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    char suit;
    int num;
    int suitn;
    cin >> suit >> num;
    switch (suit) {
    case 'S':
      suitn = 0;
      break;
    case 'H':
      suitn = 1;
      break;
    case 'C':
      suitn = 2;
      break;
    case 'D':
      suitn = 3;
      break;
    default:
      throw "input error";
    }
    card[suitn][num] = 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      char suitc[4] = {
          'S',
          'H',
          'C',
          'D',
      };
      if (card[i][j] == 0) {
        cout << suitc[i] << ' ' << j << endl;
      }
    }
  }
  return 0;
}


#include <iostream>
#include <math.h>
#include <stdbool.h>
using namespace std;
int main() {
  int n, i, x, u, ii, iii, iiii;

  char c, cc;
  bool cards[4][13]; // true=??? false=???
  while (cin >> n) {
    for (i = 0; i < n; ++i) {
      cin >> c >> u;
      if (c == 'S') {
        x = 0;
      } else if (c == 'H') {
        x = 1;
      } else if (c == 'C') {
        x = 2;
      } else if (c == 'D') {
        x = 3;
      }
      cards[x][u] = true;
    }
    for (ii = 0; ii <= 4; ++ii) {
      for (iii = 1; iii <= 13; ++iii) {
        iiii = iii;
        if (ii == 0) {
          cc = 'S';
        } else if (ii == 1) {
          cc = 'H';
        } else if (ii == 2) {
          cc = 'C';
        } else if (ii == 3) {
          cc = 'D';
        }
        if (cards[ii][iii] == false) {
          cout << cc << " " << iiii << endl;
        }
      }
    }
  }
  return 0;
}

#include <iostream>
#include <math.h>
#include <stdbool.h>
using namespace std;
int main() {
  int n, i, u, iii;
  char c;
  bool cards[4][13] = {false}; // true=??? false=???
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> c >> u;
    if (c == 'S') {
      cards[0][u - 1] = true;
    } else if (c == 'H') {
      cards[1][u - 1] = true;
    } else if (c == 'C') {
      cards[2][u - 1] = true;
    } else if (c == 'D') {
      cards[3][u - 1] = true;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[0][iii - 1] == false) {
      c = 'S';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[1][iii - 1] == false) {
      c = 'H';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[2][iii - 1] == false) {
      c = 'C';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[3][iii - 1] == false) {
      c = 'D';
      cout << c << " " << iii << endl;
    }
  }

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, x;
  int card[4][13] = {0};
  char t;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    switch (t) {
    case 'S':
      card[0][x] = 1;
      break;
    case 'H':
      card[1][x] = 1;
      break;
    case 'C':
      card[2][x] = 1;
      break;
    case 'D':
      card[3][x] = 1;
      break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          cout << 'S' << ' ' << j << endl;
          break;
        case 1:
          cout << 'H' << ' ' << j << endl;
          break;
        case 2:
          cout << 'C' << ' ' << j << endl;
          break;
        case 3:
          cout << 'D' << ' ' << j << endl;
          break;
        }
      }
    }
  }
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int n, x;
  int card[5][14] = {0};
  char t;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    switch (t) {
    case 'S':
      card[0][x] = 1;
      break;
    case 'H':
      card[1][x] = 1;
      break;
    case 'C':
      card[2][x] = 1;
      break;
    case 'D':
      card[3][x] = 1;
      break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          cout << 'S' << ' ' << j << endl;
          break;
        case 1:
          cout << 'H' << ' ' << j << endl;
          break;
        case 2:
          cout << 'C' << ' ' << j << endl;
          break;
        case 3:
          cout << 'D' << ' ' << j << endl;
          break;
        }
      }
    }
  }
  return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m, a, r = 0;
  vector<vector<int>> N;
  vector<int> M;

  cin >> n >> m;

  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < m; ++k) {
      cin >> a;
      N[i][m] = a;
    }
  }

  for (int i = 0; i < m; ++i) {
    cin >> a;
    M[i] = a;
  }

  for (int i = 0; i < n; ++i) {
    r = 0;
    for (int k = 0; k < m; ++k) {
      r += N[i][k] * M[k];
    }
    cout << r << endl;
  }

  return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int a[n][m], b[m];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", b[i]);
  }
  for (int i = 0; i < n; i++) {
    int c;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    printf("%d\\n", c);
  }
  return 0;
}

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int a[101][101], b[101];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    printf("%d\\n", c);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  int a[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; i++)
      cin >> a[i][j];

  int b[100];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  int c[100] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      c[i] += a[i][j] * b[j];

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  int a[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> a[i][j];

  int b[100];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  int c[100] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      c[i] += a[i][j] * b[j];

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;
}


#include <iostream>
using namespace std;

int main() {
  int column, row, res;

  cin >> column >> row;

  int matrix[100][100], vector_a[row];

  for (int i = 1; i <= column; i++) {
    for (int j = 1; j <= row; j++) {
      cin >> matrix[i][j];
    }
  }

  for (int i = 1; i <= row; i++) {
    cin >> vector_a[i];
  }

  for (int i = 1; i <= column; i++) {
    res = 0;
    for (int j = 1; j <= row; j++) {
      res += matrix[i][j] * vector_a[j];
    }
    cout << res << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int column, row, res;

  cin >> column >> row;

  int matrix[101][101], vector_a[101];

  for (int i = 1; i <= column; i++) {
    for (int j = 1; j <= row; j++) {
      cin >> matrix[i][j];
    }
  }

  for (int i = 1; i <= row; i++) {
    cin >> vector_a[i];
  }

  for (int i = 1; i <= column; i++) {
    res = 0;
    for (int j = 1; j <= row; j++) {
      res += matrix[i][j] * vector_a[j];
    }
    cout << res << endl;
  }
  return 0;
}


#include <cstring>
#include <iostream>
using namespace std;

int main() {
  int m, f, r, a;
  for (int i = 0;; i++) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else {
      a = m + f;
      if (m == 0 || f == 0) {
        cout << "F" << endl;
      } else if (a >= 80) {
        cout << "A" << endl;
      } else if (a < 80 && a >= 65) {
        cout << "B" << endl;
      } else if (a < 65 && a >= 50) {
        cout << "C" << endl;
      } else if (a < 50 && a >= 30) {
        if (r >= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      } else if (a < 30) {
        cout << "E" << endl;
      }
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  int A[101][101], b[101], V[101];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      V[i] += A[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << V[i] << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  double **a = new double *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new double[m];
  }
  double *b = new double[m];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    double temp = 0;
    for (int j = 0; j < m; j++) {
      temp += a[i][j] * b[j];
    }
    cout << temp << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;

  return 0;
}

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  int **a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  }
  int *b = new int[m];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < m; j++) {
      temp += a[i][j] * b[j];
    }
    cout << temp << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x[100][100] = {{}};
  int y[100] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; i++) {
      cin >> x[i][j];
    }
    for (int j = 0; j < m; j++) {
      cin >> y[j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int z = 0;
      z += x[i][j] * y[j];
      cout << z << endl;
    }
  }

  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int n, m;
  int i, j, k;
  int mat[100][100] = {{}};
  int ve[100] = {};
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  for (j = 0; j < m; j++)
    cin >> ve[j];
  for (i = 0; i < n; i++) {
    int x = 0;
    for (j = 0; j < m; j++)
      x += mat[i][j] * ve[j];
    cout << x << endl;
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, m, A[100][100], b[100], c[100];

  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; i < m; j++)
      cin >> A[i][j];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  for (int i = 0; i < n; i++) {
    c[i] = 0;
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n, m, A[100][100], b[100], c[100];

  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> A[i][j];

  for (int i = 0; i < m; i++)
    cin >> b[i];

  for (int i = 0; i < n; i++) {
    c[i] = 0;
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;

  return 0;
}


#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  // 配列の動的確保
  cin >> n >> m;
  double **a = new double *[n];
  for (int i = 0; i = n; i++) {
    a[i] = new double[m];
  }
  double *b = new double[m];
  double *c = new double[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 0;
      b[j] = 0;
    }
    c[i] = 0;
  }
  // 配列へ入力

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  // 計算、出力
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;
  delete[] c;
  return 0;
}

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  int b[m];
  int c[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 0;
      b[j] = 0;
    }
    c[i] = 0;
  }
  // 配列へ入力

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  // 計算、出力
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  return 0;
}

terminate called after throwing an instance of 'St9bad_alloc'
  what():  std::bad_alloc


#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int A[n][m];
  int b[m];
  int t;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> t;
      A[i][j] = t;
    }
  }

  for (int j = 1; j <= m; j++) {
    cin >> t;
    b[j] = t;
  }

  // int c[n] = {};
  for (int i = 1; i <= n; i++) {
    t = 0;

    for (int j = 1; j <= m; j++) {
      t += A[i][j] * b[j];
    }
    cout << t << endl;
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int A[n][m];
  int b[m];
  int t;

  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= m - 1; j++) {
      cin >> t;
      A[i][j] = t;
    }
  }

  for (int j = 0; j <= m - 1; j++) {
    cin >> t;
    b[j] = t;
  }

  // int c[n] = {};
  for (int i = 0; i <= n - 1; i++) {
    t = 0;

    for (int j = 0; j <= m - 1; j++) {
      t += A[i][j] * b[j];
    }
    cout << t << endl;
  }

  return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int m, n;
  int a[99][99], b[99], c[99], d[99];

  for (int i = 0; i < 99; i++) {
    c[i] = 0;
  }

  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  for (int k = 0; k < m; k++) {
    cin >> b[k];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      d[j] = a[i][j] * b[j];
      c[i] = c[i] + d[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int m, n;
  int a[999][999], b[999], c[999], d[999];

  for (int i = 0; i < 999; i++) {
    c[i] = 0;
  }

  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  for (int k = 0; k < m; k++) {
    cin >> b[k];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      d[j] = a[i][j] * b[j];
      c[i] = c[i] + d[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i, j;
  int x = 0;
  int y = 0;
  int z1, z2;

  int n, m;
  int **a;
  int *b;

  scanf("%d %d", &n, &m);

  a = (int **)malloc(n * sizeof(int));
  b = (int *)malloc(m * sizeof(int));

  for (i = 0; i < n; i++) {
    a[i] = (int *)malloc(m * sizeof(int));
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (j == 0) {
        scanf("%d", &x);
      } else {
        scanf(" %d", &x);
      }
      a[i][j] = x;
    }
  }

  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    b[i] = x;
  }

  for (i = 0; i < n; i++) {
    y = 0;
    for (j = 0; j < m; j++) {
      z1 = a[i][j];
      z2 = b[j];
      y += z1 * z2;
    }

    printf("%d\\n", y);
  }

  for (i = 0; i < n; i++) {
    free(a[i]);
  }

  free(a);
  free(b);

  return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i, j;
  int x = 0;
  int y = 0;
  int z1, z2;

  int n, m;
  int **a;
  int *b;

  scanf("%d %d", &n, &m);

  a = (int **)malloc(n * sizeof(int *));
  b = (int *)malloc(m * sizeof(int));

  for (i = 0; i < n; i++) {
    a[i] = (int *)malloc(m * sizeof(int));
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (j == 0) {
        scanf("%d", &x);
      } else {
        scanf(" %d", &x);
      }
      a[i][j] = x;
    }
  }

  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    b[i] = x;
  }

  for (i = 0; i < n; i++) {
    y = 0;
    for (j = 0; j < m; j++) {
      z1 = a[i][j];
      z2 = b[j];
      y += z1 * z2;
    }

    printf("%d\\n", y);
  }

  for (i = 0; i < n; i++) {
    free(a[i]);
  }

  free(a);
  free(b);

  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n, 0));
  vector<int> b(m, 0), c(n, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++)
    cin >> b[j];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << "\\n";
  }

  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m, 0));
  vector<int> b(m, 0), c(n, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++)
    cin >> b[j];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << "\\n";
  }

  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec;
  vector<vector<int>> mat;
  mat.resize(n);
  for (int i = 0; i < n; n++) {
    mat[i].resize(m);
  }
  vec.resize(m);
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < m; x++) {
      cin >> mat[y][x];
    }
  }
  for (int y = 0; y < m; y++) {
    cin >> vec[y];
  }
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < m; x++) {
      cout << mat[y][x] * vec[x] << endl;
    }
  }
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m, sum;
  cin >> n >> m;
  int mat[n * m];
  int vec[m];
  for (int i = 0; i < n * m; i++) {
    cin >> mat[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }
  for (int y = 0; y < n; y++) {
    sum = 0;
    for (int x = 0; x < m; x++) {
      sum += mat[y * m + x] * vec[x];
    }
    cout << sum << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int **A = new int *[n];
  int *B = new int[m];
  for (int i = 0; i < n; ++i)
    A[i] = new int[n];

  int tmp = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> tmp;
      A[i][j] = tmp;
    }
  }
  for (int j = 0; j < m; ++j) {
    cin >> tmp;
    B[j] = tmp;
  }

  for (int i = 0; i < n; ++i) {
    int mult = 0;
    for (int j = 0; j < m; ++j) {
      mult += A[i][j] * B[j];
    }
    cout << mult << endl;
  }

  for (int i = 0; i < n; ++i)
    delete[] A[i];
  delete[] A, B;

  return 0;
}

#include <iostream>
using namespace std;

int main(int argc, char **argv) {
  int n, m;
  cin >> n >> m;
  int **A = new int *[n];
  int *B = new int[m];
  for (int i = 0; i < n; ++i)
    A[i] = new int[m];

  int tmp = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> tmp;
      A[i][j] = tmp;
    }
  }
  for (int j = 0; j < m; ++j) {
    cin >> tmp;
    B[j] = tmp;
  }

  for (int i = 0; i < n; ++i) {
    int mult = 0;
    for (int j = 0; j < m; ++j) {
      mult += A[i][j] * B[j];
    }
    cout << mult << endl;
  }

  for (int i = 0; i < n; ++i)
    delete[] A[i];
  delete[] A, B;

  return 0;
}


#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  int A[n][m];
  int b[m];
  long long ans[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; i < m; j++) {
      ans[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  int A[n][m];
  int b[m];
  long long ans[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; j < m; j++) {
      ans[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long n, m, a[100][100], b[100], sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long n, m, a[101][101], b[101], sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int a[x][y], b[y];
  for (int i = 0; i < x; i++) {
    for (int o = 0; o < y; i++) {
      cin >> a[i][o];
    }
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < x; i++) {
    int p = 0;
    for (int o = 0; o < y; o++) {
      p = p + (a[i][o] * b[o]);
    }
    cout << p << endl;
  }
}

#include <iostream>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int a[x][y], b[y];
  for (int i = 0; i < x; i++) {
    for (int o = 0; o < y; o++) {
      cin >> a[i][o];
    }
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < x; i++) {
    int p = 0;
    for (int o = 0; o < y; o++) {
      p += a[i][o] * b[o];
    }
    cout << p << endl;
  }
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  vector<vector<int>> mx(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mx[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += mx[i][j] * v[j];
    }
    cout << ans << endl;
  }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  vector<vector<int>> mx(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mx[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += mx[i][j] * v[j];
    }
    cout << ans << endl;
  }

  return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a[100][100], b[100], i, j;
  int c[100];
  cin >> i >> j;

  for (int m = 1; m <= i; m++) {
    for (int n = 1; n <= j; n++) {
      cin >> a[m][n];
      c[n] = 0;
    }
  }

  for (int o = 1; o <= j; o++) {
    cin >> b[o];
  }
  for (int l = 1; l <= i; l++) {
    for (int k = 1; k <= j; k++) {
      c[l] += b[k] * a[l][k];
    }
  }
  for (int h = 1; h <= i; h++) {
    cout << c[h] << endl;
  }
  return 0;
}

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a[1000][1000], b[1000], i, j;
  int c[1000];
  cin >> i >> j;

  for (int m = 1; m <= i; m++) {
    for (int n = 1; n <= j; n++) {
      cin >> a[m][n];
      c[n] = 0;
    }
  }

  for (int o = 1; o <= j; o++) {
    cin >> b[o];
  }
  for (int l = 1; l <= i; l++) {
    for (int k = 1; k <= j; k++) {
      c[l] += b[k] * a[l][k];
    }
  }
  for (int h = 1; h <= i; h++) {
    cout << c[h] << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int **a, *b, *c, n, m, num;
  cin >> n >> m;

  a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  } // a[n][m]

  b = new int[m];
  c = new int[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> num;
      a[i][j] = num;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> num;
    b[i] = num;
  }

  for (int i = 0; i < n; i++) {
    c[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }

  delete[] b;
  delete[] c;
  for (int i = 0; i < m; i++) {
    delete[] a[i];
  }
  delete[] a;

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int **a, *b, *c, n, m, num;
  cin >> n >> m;

  a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  } // a[n][m]

  b = new int[m];
  c = new int[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> num;
      a[i][j] = num;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> num;
    b[i] = num;
  }

  for (int i = 0; i < n; i++) {
    c[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int A[100][100];
  int B[100];
  int C[100];
  int n = 0, m = 0;

  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int j = 0; j < m; j++) {
    cin >> B[j];
  }
  for (int i = 0; i < n; i++) {
    C[i] = 0;
    for (int j = 0; j < m; j++) {
      C[i] += A[i][j] * B[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << C[i] << endl;
  }
  return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int row, line, input, result;
  cin >> row >> line;
  vector<vector<int>> matrix1(4);
  vector<int> matrix2;
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < line; j++) {
      cin >> input;
      matrix1[i].push_back(input);
    }
  }
  for (int i = 0; i < line; i++) {
    cin >> input;
    matrix2.push_back(input);
  }
  for (int i = 0; i < row; i++) {
    result = 0;
    for (int j = 0; j < line; j++) {
      result += matrix1[i][j] * matrix2[j];
    }
    cout << result << endl;
  }
}

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int row, line, input, result;
  cin >> row >> line;
  vector<vector<int>> matrix1(row);
  vector<int> matrix2;
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < line; j++) {
      cin >> input;
      matrix1[i].push_back(input);
    }
  }
  for (int i = 0; i < line; i++) {
    cin >> input;
    matrix2.push_back(input);
  }
  for (int i = 0; i < row; i++) {
    result = 0;
    for (int j = 0; j < line; j++) {
      result += matrix1[i][j] * matrix2[j];
    }
    cout << result << endl;
  }
}


#include <iostream>
using namespace std;

int main() {
  int n, m;
  int x, y, a[n][m], b[m];
  int c[100];
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i][j] = x;
    }
  }
  for (int j = 0; j < m; j++) {
    cin >> y;
    b[j] = y;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  cout << c[n] << endl;
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int n, m;
  int x, y, a[100][100], b[100];
  int c = 0;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i][j] = x;
    }
  }
  for (int j = 0; j < m; j++) {
    cin >> y;
    b[j] = y;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    cout << c << endl;
    c = 0;
  }
  return 0;
}


#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, start, n) for (int i = start; i < n; i++)
#define And &&
#define Or ||
#define Lb cout << endl
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> b(m);
  vector<long long> c(m);
  //????????????
  rep(i, 0, n) {
    rep(j, 0, m) { cin >> a[i][j]; }
  }

  rep(i, 0, m) { cin >> b[i]; }

  rep(i, 0, n) {
    c[i] = 0;
    rep(j, 0, m) { c[i] += a[i][j] * b[j]; }
  }

  rep(i, 0, n) { cout << c[i] << endl; }
  return 0;
}

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, start, n) for (int i = start; i < n; i++)
#define And &&
#define Or ||
#define Lb cout << endl
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> b(m);
  vector<long long> c(n);
  //????????????
  rep(i, 0, n) {
    rep(j, 0, m) { cin >> a[i][j]; }
  }

  rep(i, 0, m) { cin >> b[i]; }

  rep(i, 0, n) {
    c[i] = 0;
    rep(j, 0, m) { c[i] += a[i][j] * b[j]; }
  }

  rep(i, 0, n) { cout << c[i] << endl; }
  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int n, m, N[100][100], M[100], c[100];
  cin >> n >> m;

  for (int a = 0; a < n; n++) {
    for (int b = 0; b < m; b++) {
      cin >> N[a][b];
    }
  }

  for (int a = 0; a < n; a++) {
    cin >> M[a];
  }

  for (int a = 0; a < n; a++) {
    for (int b = 0; b < m; b++) {
      c[a] = N[a][b] * M[a];
    }
  }

  for (int a = 0; a < n; a++) {
    cout << c[n] << endl;
  }
}

#include <iostream>

using namespace std;

int main() {
  int n, m, A[100][100], B[100], C[100];
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }

  for (int j = 0; j < m; j++) {
    cin >> B[j];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      C[i] += A[i][j] * B[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << C[i] << endl;
  }
}


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) Rep(i, 0, n)
#define Rep(i, k, n) for (int i = k; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())

// const int MOD = 1000000007;
// const int INF = 1<<30;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[n][m], b[m];

  // 行列
  rep1(i, n) {
    rep1(j, m) { cin >> a[i][j]; }
  }

  // 列ベクトル
  rep1(i, m) cin >> b[i];

  // 計算と表示
  rep1(i, n) {
    int c = 0;
    rep1(j, m) { c += a[i][j] * b[j]; }
    cout << c << endl;
  }
}

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) Rep(i, 0, n)
#define Rep(i, k, n) for (int i = k; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())

// const int MOD = 1000000007;
// const int INF = 1<<30;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[n + 10][m + 10], b[m + 10];

  // 行列
  rep1(i, n) {
    rep1(j, m) { cin >> a[i][j]; }
  }

  // 列ベクトル
  rep1(i, m) cin >> b[i];

  // 計算と表示
  rep1(i, n) {
    int c = 0;
    rep1(j, m) { c += a[i][j] * b[j]; }
    cout << c << endl;
  }
}


// itp1_topic6_d
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  int A[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; m++)
      cin >> A[i][j];

  int B[100];
  for (int i = 0; i < m; i++)
    cin >> B[i];

  int C[100] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      C[i] += A[i][j] * B[j];

  for (int i = 0; i < n; i++)
    cout << C[i] << endl;

  return 0;
}

// itp1_topic6_d
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int A[100][100];
  int b[100];
  int c[100];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++)
    cin >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++)
    cout << c[i] << endl;

  return 0;
}


#include <iostream>

int main() {
  using namespace std;
  int A_num, b_num, A_count, b_count, data, row = 0, col = 0;
  cin >> A_num >> b_num;
  A_count = A_num * b_num;
  b_count = b_num;
  int **A = (int **)malloc(sizeof(int *) * A_num);
  for (int i = 0; i < b_num; i++) {
    A[i] = (int *)malloc(sizeof(int) * b_num);
  }
  int *b = (int *)malloc(sizeof(int) * b_num);
  while (A_count > 0) {
    cin >> data;
    A[row][col] = data;
    col++;
    if (col == b_num) {
      row++;
      col = 0;
    }
    A_count--;
  }
  col = 0;
  while (b_count > 0) {
    cin >> data;
    b[col] = data;
    col++;
    b_count--;
  }
  for (int i = 0; i < A_num; i++) {
    int sum = 0;
    for (int j = 0; j < b_num; j++) {
      sum += A[i][j] * b[j];
    }
    cout << sum << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>

int main() {
  using namespace std;
  int A_num, b_num, A_count, b_count, data, row = 0, col = 0;
  cin >> A_num >> b_num;
  A_count = A_num * b_num;
  b_count = b_num;
  vector<vector<int>> A(A_num, vector<int>(b_num));
  vector<int> b(b_num);
  while (A_count > 0) {
    cin >> data;
    A[row][col] = data;
    col++;
    if (col == b_num) {
      row++;
      col = 0;
    }
    A_count--;
  }
  col = 0;
  while (b_count > 0) {
    cin >> data;
    b[col] = data;
    col++;
    b_count--;
  }
  for (int i = 0; i < A_num; i++) {
    int sum = 0;
    for (int j = 0; j < b_num; j++) {
      sum += A[i][j] * b[j];
    }
    cout << sum << endl;
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int a[1000][1000], b[1000];
  int n, m;
  int i, j;

  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; i++) {
      cin >> a[i][j];
    }
  }

  for (j = 0; j < m; j++)
    cin >> b[j];

  for (i = 0; i < n; i++) {
    int h = 0;
    for (j = 0; j < m; i++) {
      h += a[i][j] * b[j];
    }
    cout << h << endl;
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {

  int n, m, b[1000], a[1000][1000], SUM[1000];

  for (int i = 1; i < 1000; i++) {
    SUM[i] = 0;
  }

  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {

      cin >> a[i][j];
    }
  }

  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      SUM[i] += a[i][j] * b[j];
    }
    cout << SUM[i] << endl;
  }

  return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
  int a[101][101];
  int b[101];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += a[i][j] * b[j];
    }
    printf("%d\\n", ans);
  }
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> mtr(3, vector<int>(4));
  vector<int> vec(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mtr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }

  for (int i = 0; i < n; i++) {
    int ret = 0;
    for (int j = 0; j < m; j++) {
      ret += mtr[i][j] * vec[j];
    }
    cout << ret << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> mtr(n, vector<int>(m));
  vector<int> vec(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mtr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }

  for (int i = 0; i < n; i++) {
    int ret = 0;
    for (int j = 0; j < m; j++) {
      ret += mtr[i][j] * vec[j];
    }
    cout << ret << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {

  int gyo, retu;
  int sum[100] = {0};
  int vec1[retu][gyo];
  int vec2[gyo];

  cin >> retu >> gyo;

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      cin >> vec1[i][j];
    }
  }

  for (int i = 0; i < gyo; i++) {
    cin >> vec2[i];
  }

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      sum[i] += vec1[i][j] * vec2[j];
    }
    cout << sum[i] << endl;
  }
}

#include <iostream>
using namespace std;

int main() {

  int gyo, retu;
  int sum[100] = {0};
  int vec1[100][100];
  int vec2[100];

  cin >> retu >> gyo;

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      cin >> vec1[i][j];
    }
  }

  for (int i = 0; i < gyo; i++) {
    cin >> vec2[i];
  }

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      sum[i] += vec1[i][j] * vec2[j];
    }
    cout << sum[i] << endl;
  }
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
  long n = 0;
  long m = 0;
  cin >> n >> m;
  vector<vector<long>> a(n);
  vector<long> b(m, 0);
  vector<long> c(m, 0);
  for (long i = 0; i < n; i++) {
    a[i].resize(m);
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      a[i][j] = 0;
      cin >> a[i][j];
    }
  }
  for (long i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (long i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  long n = 0;
  long m = 0;
  cin >> n >> m;
  vector<vector<long>> a(n);
  vector<long> b(m, 0);
  vector<long> c(n, 0);
  for (long i = 0; i < n; i++) {
    a[i].resize(m);
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      a[i][j] = 0;
      cin >> a[i][j];
    }
  }
  for (long i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (long i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[99][99] = {};
  int b[99] = {};

  int x = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i][j] = x;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> x;
    b[i] = x;
  }

  int c;
  for (int i = 0; i < n; i++) {
    c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    cout << c << endl;
  }
}

#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[100][100] = {};
  int b[100] = {};

  int x = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i][j] = x;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> x;
    b[i] = x;
  }

  int c;
  for (int i = 0; i < n; i++) {
    c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    cout << c << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int m, n;
  int a[1000][1000];
  int b[1000];
  cin >> m >> n;

  for (int i = 1; i <= m; i++) {
    for (int g = 1; g <= n; g++) {
      cin >> a[i][g];
    }
  }
  for (int g = 1; g <= n; g++) {
    cin >> b[g];
  }

  int c[1000] = {};
  for (int i = 1; i <= m; i++) {
    for (int g = 1; g <= n; g++) {
      c[i] += a[i][g] * b[g];
    }
  }

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

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n][m], b[m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  vector<int> ans(m, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ans[i] += a[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++)
    cout << ans[i] << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[101][101], b[101];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  vector<int> ans(1001, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ans[i] += a[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++)
    cout << ans[i] << endl;
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;

  int **a = new int *[r + 1];
  for (int i = 0; i <= c; i++) {
    a[i] = new int[c + 1];
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      a[i][c] = 0;
      a[r][j] = 0;
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
    cout << a[i][c];
    cout << endl;
  }
  for (int j = 0; j < c; j++) {
    cout << a[r][j] << " ";
    a[r][c] += a[r][j];
  }
  cout << a[r][c] << endl;
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;

  int **a = new int *[r + 1];
  for (int i = 0; i <= r; i++) {
    a[i] = new int[c + 1];
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      a[i][c] = 0;
      a[r][j] = 0;
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
    cout << a[i][c];
    cout << endl;
  }
  for (int j = 0; j < c; j++) {
    cout << a[r][j] << " ";
    a[r][c] += a[r][j];
  }
  cout << a[r][c] << endl;
  delete[] a;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int r, c, sum, total;
  total = 0;
  cin >> r >> c;
  int **sheet = new int *[r + 1];
  for (int i = 0; i < r; i++) {
    sheet[i] = new int[c + 1];
  }
  for (int y = 0; y < r; y++) {
    sum = 0;
    for (int x = 0; x < c; x++) {
      cin >> sheet[y][x];
      sum += sheet[y][x];
    }
    sheet[y][c] = sum;
  }
  for (int x = 0; x < c; x++) {
    sum = 0;
    for (int y = 0; y < r; y++) {
      sum += sheet[y][x];
      total += sheet[y][x];
    }
    sheet[r][x] = sum;
  }
  sheet[r][c] = total;
  for (int y = 0; y < r + 1; y++) {
    for (int x = 0; x < c + 1; x++) {
      cout << sheet[y][x] << " ";
    }
    cout << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int r, c, sum, total;
  total = 0;
  cin >> r >> c;
  int **sheet = new int *[r + 1];
  for (int i = 0; i < r + 1; i++) {
    sheet[i] = new int[c + 1];
  }
  for (int y = 0; y < r; y++) {
    sum = 0;
    for (int x = 0; x < c; x++) {
      cin >> sheet[y][x];
      sum += sheet[y][x];
    }
    sheet[y][c] = sum;
  }
  for (int x = 0; x < c; x++) {
    sum = 0;
    for (int y = 0; y < r; y++) {
      sum += sheet[y][x];
      total += sheet[y][x];
    }
    sheet[r][x] = sum;
  }
  sheet[r][c] = total;
  for (int y = 0; y < r + 1; y++) {
    for (int x = 0; x < c + 1; x++) {
      if (x == c)
        cout << sheet[y][x];
      else
        cout << sheet[y][x] << " ";
    }
    cout << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {

  int hyo[100][100];
  int r, c, n;
  while (1) {

    for (int i = 0; i < 100; i++) {
      for (int j = 0; j < 100; j++) {
        hyo[i][j] = 0;
      }
    }

    cin >> r >> c;

    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        cin >> n;
        hyo[i][j] = n;
        hyo[i][c] += hyo[i][j];
        hyo[r][j] += hyo[i][j];
      }
      hyo[r][c] += hyo[i][c];
    }

    for (int i = 0; i <= r; i++) {
      for (int j = 0; j <= c; j++) {
        cout << hyo[i][j] << " ";
      }
      cout << endl;
    }
  }
}

#include <iostream>
using namespace std;

int main(int argc, char const *argv[]) {
  int c, r;
  cin >> c >> r;

  int a[101][101] = {0};

  for (int i = 0; i < c; i++) {
    for (int j = 0; j < r; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < c; i++) {
    for (int j = 0; j < r; j++) {
      // cout << a[i][r] << endl;
      a[i][r] += a[i][j];
      a[c][j] += a[i][j];
    }
    a[c][r] += a[i][r];
  }

  for (int i = 0; i <= c; i++) {
    cout << a[i][0];
    for (int j = 1; j <= r; j++) {
      cout << ' ' << a[i][j];
    }
    cout << endl;
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int r, c, arr[100][100] = {};
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> arr[i][j];
      arr[r][j] += arr[i][j];
      arr[i][c] += arr[i][j];
      arr[r][c] += arr[i][j];
    }
  }

  for (int m = 0; m <= r; m++) {
    for (int k = 0; k <= c; k++) {
      cout << arr[m][k];

      if (k == c) {
        cout << endl;
      } else {
        cout << ' ';
      }
    }
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int r, c, arr[101][101] = {};
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> arr[i][j];
      arr[r][j] += arr[i][j];
      arr[i][c] += arr[i][j];
      arr[r][c] += arr[i][j];
    }
  }

  for (int m = 0; m <= r; m++) {
    for (int k = 0; k <= c; k++) {
      cout << arr[m][k];

      if (k == c) {
        cout << endl;
      } else {
        cout << ' ';
      }
    }
  }

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int table[101][101] = {{}};
  int r, c, i, j, total;
  cin >> r >> c;
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) {
      cin >> table[i][j];
    }
  }
  for (i = 1; i <= r; i++) {
    total = 0;
    for (j = 1; j <= c; j++) {
      total += table[i][j];
    }
    table[i][c + 1] = total;
  }

  for (j = 1; j <= c + 1; j++) {
    total = 0;
    for (i = 1; i <= r; i++) {
      total += table[i][j];
    }
    table[r + 1][j] = total;
  }

  for (i = 1; i <= r + 1; i++) {
    cout << table[i][1];
    for (j = 2; j <= c + 1; j++) {
      cout << " " << table[i][j];
    }
    cout << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int table[101][101] = {{}};
  int i, j, r, c;
  cin >> r >> c;
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      cin >> table[i][j];
    }
  }

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      table[i][c] += table[i][j];
      table[r][j] += table[i][j];
      table[r][c] += table[i][j];
    }
  }

  for (i = 0; i <= r; i++) {
    for (j = 0; j <= c; j++) {
      if (j)
        cout << " " << table[i][j];
      else
        cout << table[i][j];
    }
    cout << endl;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  int a[n + 1][m + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      a[i][m + 1] += a[i][j];
      a[n + 1][j] += a[i][j];
    }
  }

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < m + 1; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> v(m + 1, 0);
  vector<vector<int>> a(n + 1, v);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      // cout << "a[" << i << ", " << j << "] ?";
      cin >> a[i][j];
      a[i][m] += a[i][j];
      a[n][j] += a[i][j];
      a[n][m] += a[i][j];
    }
  }

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < m; j++) {
      cout << a[i][j] << " ";
    }
    cout << a[i][m] << endl;
    // cout << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, sum;
  cin >> r >> c;
  int a[100][100] = {};

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      cin >> a[i][j];

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      a[r][c] += a[i][j];

  for (int i = 0; i < r; i++) {
    sum = 0;
    for (int j = 0; j < c; j++)
      sum += a[i][j];
    a[i][c] = sum;
  }

  for (int j = 0; j < c; j++) {
    sum = 0;
    for (int i = 0; j < r; i++)
      sum += a[i][j];
    a[r][j] = sum;
  }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, sum;
  cin >> r >> c;
  int a[101][101] = {};

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      cin >> a[i][j];

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      a[r][c] += a[i][j];

  for (int i = 0; i < r; i++) {
    sum = 0;
    for (int j = 0; j < c; j++)
      sum += a[i][j];
    a[i][c] = sum;
  }

  for (int j = 0; j < c; j++) {
    sum = 0;
    for (int i = 0; i < r; i++)
      sum += a[i][j];
    a[r][j] = sum;
  }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }
}


#include <iostream>
using namespace std;
int main() {
  int hyo[100][100] = {0};
  int r, c;
  cin >> r;
  cin >> c;
  for (int i = 0; i < r; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      cin >> hyo[i][i2];
    }
  }
  for (int i = 0; i < r; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      hyo[i][c] += hyo[i][i2];
    }
  }
  for (int i = 0; i < c; i++) {
    for (int i2 = 0; i2 < r; i2++) {
      hyo[r][i] += hyo[i2][i];
    }
  }
  for (int i = 0; i < r; i++) {
    hyo[r][c] += hyo[i][c];
  }
  for (int i = 0; i < r + 1; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      cout << hyo[i][i2] << " ";
    }
    cout << hyo[i][c] << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int hyo[1000][1000] = {0};
  int r, c;
  cin >> r;
  cin >> c;
  for (int i = 0; i < r; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      cin >> hyo[i][i2];
    }
  }
  for (int i = 0; i < r; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      hyo[i][c] += hyo[i][i2];
    }
  }
  for (int i = 0; i < c; i++) {
    for (int i2 = 0; i2 < r; i2++) {
      hyo[r][i] += hyo[i2][i];
    }
  }
  for (int i = 0; i < r; i++) {
    hyo[r][c] += hyo[i][c];
  }
  for (int i = 0; i < r + 1; i++) {
    for (int i2 = 0; i2 < c; i2++) {
      cout << hyo[i][i2] << " ";
    }
    cout << hyo[i][c] << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

unsigned long long int i, j, k, counter, a, b;
unsigned long long int t, y;
unsigned long long int ef[100][100];
int main() {
  counter = 0;
  a = 0;
  b = 0;
  cin >> t >> y;
  for (i = 0; i < t; i++) {
    for (j = 0; j < y; j++) {
      cin >> ef[i][j];
      cout << ef[i][j] << ' ';
      a += ef[i][j];
    }
    ef[i][y] = a;
    cout << ef[i][y] << endl;
    a = 0;
  }
  ///////////////////
  for (j = 0; j <= y; j++) {
    for (i = 0; i < t; i++) {
      k += ef[i][j];
    }
    ef[t][j] = k;
    k = 0;
  }
  ////////////////
  for (i = 0; i < y; i++) {
    cout << ef[t][i] << ' ';
  }
  cout << ef[t][y] << endl;

  return 0;
}

#include <iostream>
using namespace std;

unsigned long long int i, j, k, counter, a, b;
unsigned long long int t, y;
unsigned long long int ef[110][110];
int main() {
  counter = 0;
  a = 0;
  b = 0;
  cin >> t >> y;
  for (i = 0; i < t; i++) {
    for (j = 0; j < y; j++) {
      cin >> ef[i][j];
      cout << ef[i][j] << ' ';
      a += ef[i][j];
    }
    ef[i][y] = a;
    cout << ef[i][y] << endl;
    a = 0;
  }
  ///////////////////
  for (j = 0; j <= y; j++) {
    for (i = 0; i < t; i++) {
      k += ef[i][j];
    }
    ef[t][j] = k;
    k = 0;
  }
  ////////////////
  for (i = 0; i < y; i++) {
    cout << ef[t][i] << ' ';
  }
  cout << ef[t][y] << endl;
  return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int eval(int x, int y) {
  int i, j, k, cnt = 0;
  for (int i = 1; i <= x; i++) {
    for (int j = i + 1; j <= x; j++) {
      for (int k = j + 1; k <= x; k++) {
        if (i + j + k == y) {
          cnt++;
        }
      }
    }
  }
  return cnt;
}

int main() {

  int x, y;
  while (cin >> x >> y, x + y != 0) {
    cout << eval(x, y) << endl;
  }
}

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int data[101][101] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> data[i][j];
      data[i][m] += data[i][j];
      data[n][j] += data[i][j];
      data[n][m] += data[i][j];
    }
  }

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < m + 1; j++) {
      cout << data[i][j];
      if (j != m) {
        cout << " ";
      }
    }
    cout << endl;
  }
}


#include <iostream>
using namespace std;

int main() {

  int r, c, sum;
  int a[100][100] = {0};
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
    cout << a[i][c] << endl;
  }

  for (int j = 0; j < c; j++) {
    cout << a[r][j] << " ";
    sum += a[r][j];
  }
  cout << sum << endl;
  return 0;
}

#include <iostream>
using namespace std;

int main() {

  int r, c, sum;
  int a[101][101] = {0};
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
    cout << a[i][c] << endl;
  }

  for (int j = 0; j < c; j++) {
    cout << a[r][j] << " ";
    sum += a[r][j];
  }
  cout << sum << endl;
  return 0;
}


#include <iostream>
#include <vector>

int main() {

  while (true) {
    int r, c;
    std::cin >> r >> c;
    if (r == 0 && c == 0)
      break;

    std::vector<std::vector<int>> mat;
    // mat[r][c]

    mat.resize(r + 1);
    for (int i = 0; i < r + 1; i++) {
      mat[i].resize(c + 1);
    }

    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        std::cin >> mat[i][j];
      }
    }

    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        mat[i][c] += mat[i][j];
      }
    }

    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c + 1; j++) {
        mat[r][j] += mat[i][j];
      }
    }

    for (int i = 0; i < r + 1; i++) {
      for (int j = 0; j < c + 1; j++) {
        std::cout << mat[i][j];
        if (j != c)
          std::cout << " ";
      }
      std::cout << std::endl;
    }
  }
  return 0;
}

#include <iostream>
#include <vector>

int main() {

  int r, c;
  std::cin >> r >> c;

  std::vector<std::vector<int>> mat;

  mat.resize(r + 1);
  for (int i = 0; i < r + 1; i++) {
    mat[i].resize(c + 1);
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      std::cin >> mat[i][j];
    }
  }

  // anticipating mat[i][c] == 0...
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      mat[i][c] += mat[i][j];
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c + 1; j++) {
      mat[r][j] += mat[i][j];
    }
  }

  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      std::cout << mat[i][j];
      if (j != c)
        std::cout << " ";
    }
    std::cout << std::endl;
  }

  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int r, c, S[100][100] = {0};
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> S[i][j];
      S[i][c] += S[i][j];
    }
  }

  for (int i = 0; i <= c; i++) {
    for (int j = 0; j < r; j++) {
      S[r][i] += S[j][i];
    }
  }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << S[i][j];
    }
    cout << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int r, c, S[101][101] = {0};
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> S[i][j];
      S[i][c] += S[i][j];
    }
  }

  for (int i = 0; i <= c; i++) {
    for (int j = 0; j < r; j++) {
      S[r][i] += S[j][i];
    }
  }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << S[i][j];
    }
    cout << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main(void) {
  int r, c, a[101][101], sum_r = 0, sum_c = 0, sum_all = 0;
  while (1) {
    cin >> r >> c;
    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        cin >> a[i][j];
        cout << a[i][j] << " ";
        sum_r += a[i][j];
        sum_all += a[i][j];
      }
      cout << sum_r << endl;
      sum_r = 0;
    }
    for (int j = 0; j < c; j++) {
      for (int i = 0; i < r; i++) {
        sum_c += a[i][j];
        cout << sum_c << " ";
      }
      sum_c = 0;
    }
    cout << sum_all << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;

int main(void) {
  int r, c, a[101][101], sum_r = 0, sum_c = 0, sum_all = 0;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      cout << a[i][j] << " ";
      sum_r += a[i][j];
      sum_all += a[i][j];
    }
    cout << sum_r << endl;
    sum_r = 0;
  }
  for (int j = 0; j < c; j++) {
    for (int i = 0; i < r; i++) {
      sum_c += a[i][j];
    }
    cout << sum_c << " ";
    sum_c = 0;
  }
  cout << sum_all << endl;
  return 0;
}


#include <cstdlib>
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int **numArray;

void createArray(int row, int column) {
  int i;
  numArray = (int **)calloc(column, sizeof(int *));
  for (i = 0; i < column; i++)
    numArray[i] = (int *)calloc(row, sizeof(int));
}

void populateArray(int row, int column) {
  int i, j;
  for (i = 0; i < row - 1; i++)
    for (j = 0; j < column - 1; j++)
      cin >> numArray[i][j];
}

void sumArray(int row, int column) {
  int i, j, k, rsum = 0, csum = 0, fsum = 0;
  for (i = 0; i < row; i++) {
    for (j = 0; j < column; j++) {
      if (j < column - 1)
        csum += numArray[i][j];
      else
        numArray[i][j] = csum;

      if (j < row - 1)
        rsum += numArray[j][i];
      else
        numArray[j][i] = rsum;
    }
    csum = 0;
    rsum = 0;
  }

  numArray[row - 1][column - 1] = 0;
  for (k = 0; k < row; k++)
    fsum += numArray[k][column - 1];
  numArray[row - 1][column - 1] = fsum;
}

void drawArray(int row, int column) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < column - 1; j++)
      cout << numArray[i][j] << " ";
    cout << numArray[i][column - 1] << endl;
  }
}

int main() {
  int i, r, c;
  cin >> r >> c;
  createArray(r + 1, c + 1);
  populateArray(r + 1, c + 1);
  sumArray(r + 1, c + 1);
  drawArray(r + 1, c + 1);

  for (i = 0; i < c + 1; i++)
    free(numArray[i]);
  free(numArray);
  return 0;
}

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int *numArray;

void createArray(int row, int column) {
  int i;
  numArray = new int[row * column];
  for (i = 0; i < (row * column); i++)
    numArray[i] = 0;
}

void populateArray(int row, int column) {
  int i, j;
  for (i = 0; i < row - 1; i++)
    for (j = 0; j < column - 1; j++)
      cin >> numArray[i * column + j];
}

void sumArray(int row, int column) {
  int i, j, rsum = 0, csum = 0;
  for (i = 0; i < row - 1; i++) {
    for (j = 0; j < column - 1; j++)
      rsum += numArray[i * column + j];
    numArray[i * column + column - 1] = rsum;
    rsum = 0;
  }

  for (j = 0; j < column; j++) {
    for (i = 0; i < row - 1; i++)
      csum += numArray[i * column + j];
    numArray[(row - 1) * column + j] = csum;
    csum = 0;
  }
}

void drawArray(int row, int column) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < column - 1; j++)
      cout << numArray[i * column + j] << " ";
    cout << numArray[i * column + column - 1] << endl;
  }
}

int main() {
  int row, column;
  cin >> row >> column;
  createArray(row + 1, column + 1);
  populateArray(row + 1, column + 1);
  sumArray(row + 1, column + 1);
  drawArray(row + 1, column + 1);
  delete[] numArray;
  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  int num[101][101] = {};
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      cin >> num[i][j];

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      num[r][c] += num[i][j];

  for (int i = 0; i < r; i++) {
    int sum = 0;
    for (int j = 0; j < c; j++)
      sum += num[i][j];
    num[i][c] = sum;
  }
  for (int j = 0; j < c; j++) {
    int sum = 0;
    for (int i = 0; i < r; j++)
      sum += num[i][j];
    num[r][j] = sum;
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << num[i][j];
    }
    cout << endl;
  }
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  int num[101][101] = {};
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      cin >> num[i][j];

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      num[r][c] += num[i][j];

  for (int i = 0; i < r; i++) {
    int sum = 0;
    for (int j = 0; j < c; j++)
      sum += num[i][j];
    num[i][c] = sum;
  }
  for (int j = 0; j < c; j++) {
    int sum = 0;
    for (int i = 0; i < r; i++)
      sum += num[i][j];
    num[r][j] = sum;
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j)
        cout << " ";
      cout << num[i][j];
    }
    cout << endl;
  }
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int r, c, e, sum, sum2, sheet[100][100];
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    sum = 0;
    for (int j = 0; j < c; j++) {
      cin >> e;
      sheet[i][j] = e;
      sum += e;
    }

    sheet[i][c] = sum;
  }

  sum2 = 0;
  for (int i = 0; i < c; i++) {
    sum = 0;
    for (int j = 0; j < r; j++) {
      sum += sheet[j][i];
    }

    sheet[r][i] = sum;
    sum2 += sum;
  }

  sheet[r][c] = sum2;

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j == c) {
        cout << sheet[i][j] << endl;
      } else {
        cout << sheet[i][j] << " ";
      }
    }
  }

  return 0;
}

#include <iostream>
using namespace std;

int main() {
  int r, c, e, sum, sum2, sheet[101][101];
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    sum = 0;
    for (int j = 0; j < c; j++) {
      cin >> e;
      sheet[i][j] = e;
      sum += e;
    }

    sheet[i][c] = sum;
  }

  sum2 = 0;
  for (int i = 0; i < c; i++) {
    sum = 0;
    for (int j = 0; j < r; j++) {
      sum += sheet[j][i];
    }

    sheet[r][i] = sum;
    sum2 += sum;
  }

  sheet[r][c] = sum2;

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j == c) {
        cout << sheet[i][j] << endl;
      } else {
        cout << sheet[i][j] << " ";
      }
    }
  }

  return 0;
}


#include <iostream>
using namespace std;
int main() {
  int r, c;
  int a[100][100] = {0};
  int x = 0;
  int y = 0;

  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      x += a[i][j];
    }
    a[i][c] = x;
    x = 0;
  }
  for (int j = 0; j <= c; j++) {
    for (int i = 0; i < r; i++) {
      y += a[i][j];
    }
    a[r][j] = y;
    y = 0;
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << a[i][j];
      if (j < c)
        cout << " ";
    }
    cout << endl;
  }
}

#include <iostream>
using namespace std;
int main() {
  int r, c;
  int a[101][101] = {0};
  int x = 0;
  int y = 0;

  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      x += a[i][j];
    }
    a[i][c] = x;
    x = 0;
  }
  for (int j = 0; j <= c; j++) {
    for (int i = 0; i < r; i++) {
      y += a[i][j];
    }
    a[r][j] = y;
    y = 0;
  }
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << a[i][j];
      if (j < c)
        cout << " ";
    }
    cout << endl;
  }
}


#include <iostream>
using namespace std;
int main() {
  int a[200][200], r, c, sum;
  sum = 0;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; c++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; c++) {
      cout << a[i][j] << " ";
      sum += a[i][j];
      if (j = c - 1) {
        a[i][j + 1] = sum;
        cout << sum << endl;
        sum = 0;
      }
    }
  } // r行まで入力終了
  for (int j = 0; j < c; j++) {
    for (int i = 0; i < r; i++) {
      sum += a[i][j];
      if (i == r - 1) {
        a[i + 1][j] = sum;
        cout << sum << " ";
        sum = 0;
      }
    }
  } // 最後以外全部終わり
  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      sum += a[i][j];
    }
  }
  cout << sum << endl;
  return 0;
}

#include <iostream>
using namespace std;
int main() {
  int a[200][200], r, c, sum;
  sum = 0;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cout << a[i][j] << " ";
      sum += a[i][j];
    }
    a[i][c] = sum;
    cout << sum << endl;
    sum = 0;
  }
  for (int j = 0; j < c; j++) {
    for (int i = 0; i < r; i++) {
      sum += a[i][j];
      if (i == r - 1) {
        a[i + 1][j] = sum;
        cout << sum << " ";
        sum = 0;
      }
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      sum += a[i][j];
    }
  }

  cout << sum << endl;
  return 0;
}


#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  int r, c;
  int hyo[100][100];
  int ans, final_ans;

  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> hyo[i][j];
    }
  }

  for (int i = 0; i < r; i++) {
    ans = 0;
    for (int j = 0; j < c; j++) {
      ans += hyo[i][j];
    }
    hyo[i][c] = ans;
  }

  final_ans = 0;

  for (int j = 0; j < c; j++) {
    ans = 0;
    for (int i = 0; i < r; i++) {
      ans += hyo[i][j];
    }
    hyo[r][j] = ans;
    final_ans += ans;
  }

  hyo[r][c] = final_ans;

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << hyo[i][j];
      if (j != c)
        cout << " ";
    }
    cout << endl;
  }

  return 0;
}

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  int r, c;
  int hyo[1000][1000];
  int ans, final_ans;

  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> hyo[i][j];
    }
  }

  for (int i = 0; i < r; i++) {
    ans = 0;
    for (int j = 0; j < c; j++) {
      ans += hyo[i][j];
    }
    hyo[i][c] = ans;
  }

  final_ans = 0;

  for (int j = 0; j < c; j++) {
    ans = 0;
    for (int i = 0; i < r; i++) {
      ans += hyo[i][j];
    }
    hyo[r][j] = ans;
    final_ans += ans;
  }

  hyo[r][c] = final_ans;

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << hyo[i][j];
      if (j != c)
        cout << " ";
    }
    cout << endl;
  }

  return 0;
}