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

int main() {
    map<char,int> digits = {
        {'0',6},{'1',2},{'2',5},{'3',5},{'4',4},{'5',5},{'6',6},{'7',3},{'8',7},{'9',6}
    };
    int t; cin >> t;
    for (int i = 0; i < t; ++i) {
        string a; cin >> a;
        int sticks = 0;
        for(char ch : a) sticks += digits[ch];
        cout << sticks << ' ';
    }
    return 0;
}