#include <bits/stdc++.h>
using namespace std;
char strA[100];
int main() {
  int N;
  vector<string> ips;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf(" %s", strA);
    ips.push_back(strA);
  }
  vector<string> ret;
  for (int i = 0; i < N; i++) {
    int sz = 0;
    int blocks = 0;
    string str = ips[i];
    bool used = false;
    for (int j = 0; j < ips[i].size();) {
      if (str[j] == ':' && str[j + 1] != ':') {
        j++;
        continue;
      }
      if (str[j] == ':' && str[j + 1] == ':') {
        int bs = 0;
        bool ist = false;
        for (int v = j + 2; v < str.size(); v++) bs += str[v] == ':';
        if (j + 2 < str.size()) blocks += bs + 1;
        if (!used && blocks < 8)
          printf("0000");
        else if (blocks < 8)
          printf(":0000");
        for (int k = 1; k < 8 - blocks; k++) printf(":0000");
        if (j + 2 >= str.size())
          break;
        else {
          j += 2;
          continue;
        }
      }
      used = true;
      sz = 0;
      int kA = j;
      for (kA = j; kA < j + 4 && kA < str.size() && str[kA] != ':'; kA++) sz++;
      if (j) printf(":");
      for (int v = 0; v < 4 - sz; v++) printf("0");
      for (int v = j; v < j + sz && v < str.size(); v++) printf("%c", str[v]);
      j = kA;
      blocks++;
    }
    printf("\n");
  }
  return 0;
}
