#include <bits/stdc++.h>
using namespace std;
int main() {
  char szBuffer[256];
  char szTemp[8];
  int n;
  cin >> n;
  cin.getline(szBuffer, 256);
  int count;
  int pos;
  int ccount = 0;
  for (int i = 0; i < n; i++) {
    cin.getline(szBuffer, 256);
    pos = 0;
    ccount = 0;
    if (szBuffer[0] != ':') ccount++;
    for (int j = 0; szBuffer[j]; j++) {
      if (szBuffer[j] == ':' && szBuffer[j + 1] != ':' && szBuffer[j + 1]) {
        ccount++;
      }
    }
    for (int j = 0; szBuffer[j]; j++) {
      if (szBuffer[j] == ':' && szBuffer[j + 1] == ':') {
        for (int k = 0; k < 8 - ccount; k++) {
          cout << "0000";
          if (pos != 7) cout << ":";
          pos++;
        }
        j++;
        continue;
      }
      if (szBuffer[j] != ':') {
        count = 0;
        int k;
        for (k = j; k - j < 4 && szBuffer[k] != ':' && szBuffer[k]; k++) {
          szTemp[k - j] = szBuffer[k];
          count++;
        }
        j = k - 1;
        for (k = 0; k < 4 - count; k++) {
          cout << "0";
        }
        for (k = 0; k < count; k++) {
          cout << szTemp[k];
        }
        if (pos != 7) cout << ":";
        pos++;
      }
    }
    cout << endl;
  }
  return 0;
}
