#include <iostream>

using namespace std;

/* Main body of program */
void process(void)
{
    int count;
    
    /* Read how many numbers there are to round */    
    cin >> count;
    
    /* Read in and round each number */
    for(int i = 0; i < count; i++) {
        int value;

        /* Read in the input number */
        cin >> value;
        
        /* Keep rounding until all digits in value are rounded */
        for(int magnitude = 1; value > (magnitude * 10); magnitude *= 10) {    
            int digit = (value / magnitude) % 10;
            
            if(digit >= 5) {
                value += (10 - digit) * magnitude;
            }
            else {
                value -= (digit * magnitude);
            }
        }
        
        /* Print out the rounded number */
        cout << value << endl;
    }
    
}

/* Run program and print out any exceptions that occur */
int main(void)
{
    /* Throw exceptions on EOF or failed data extraction in >> operator */
    cin.exceptions(ios::eofbit | ios::failbit);

    /* Run main body of code */
    try {
        process();
    }
    
    /* Catch any internally generated exceptions */
    catch(char const *e) {
        cerr << "Exception: " << e << endl;
    }
    
    /* Catch unexpected EOF or bad input data */
    catch(ios::failure const &e) {
        cerr << "Unexpected EOF or data type mismatch on input" << endl;
    }

    return 0;
}