// ${url}
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

// Input macros.
// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! read_line {
    ($t:tt) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().parse::<$t>().unwrap()
        }
    }
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

// ===

const MOD: i64 = 1e9 as i64 + 7;

type SquareMatrix = Vec<Vec<i64>>;

fn eye(n: usize) -> SquareMatrix {
    let mut data = dvec!(0; n, n);
    for i in 0..n {
        data[i][i] = 1;
    }
    data
}

fn pow(a: SquareMatrix, mut n: i64) -> SquareMatrix {
    let mut ret = eye(a.len());
    let mut aa = a.clone();
    while n >= 1 {
        if n & 1 == 1 {
            ret = multiply(&ret, &aa);
        }
        aa = multiply(&aa, &aa);
        n /= 2;
    }
    ret
}

fn multiply(left: &SquareMatrix, right: &SquareMatrix) -> SquareMatrix {
    let n = left.len();
    let mut temp = dvec![0; n, n];
    let mod2 = MOD*MOD;
    for i in 0..n {
        for k in 0..n {
            for j in 0..n {
                temp[i][j] += left[i][k] * right[k][j];
                if temp[i][j] >= mod2 {
                    temp[i][j] -= mod2;
                }
            }
        }
    }
    for i in 0..n {
        for j in 0..n {
            temp[i][j] %= MOD;
        }
    }
    temp
}

fn multiply_one(left: &SquareMatrix, w: &Vec<i64>) -> Vec<i64> {
    let n = w.len();
    let mut ret = vec![0; n];
    let mod2 = MOD*MOD;
    for i in 0..n {
        for j in 0..n {
            ret[i] += left[i][j] * w[j];
            if ret[i] >= mod2 {
                ret[i] -= mod2
            }
        }
        ret[i] %= MOD;
    }
    ret
}

//===

fn add(from: usize, to: usize, mat: &mut SquareMatrix) {
    mat[to][from] += 1;
}

fn encode(phase: usize, flag: usize) -> usize {
    phase * 2 + flag
}

const MAX_SIZE: usize = 21;

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    };

    let mut mat = dvec![0; MAX_SIZE, MAX_SIZE];
    for i in 0..5 {
        for mod2 in 0..2 {
            // place same
            add(encode(i, mod2), encode(i, mod2^1), &mut mat);
            // go next
            for j in i+1..=5 {
                if mod2 == 0 {
                    continue;
                }
                add(encode(i, mod2), encode(j, mod2^1), &mut mat);
            }
        }
    }
    for i in 5..10 {
        for placed in 0..2 {
            for to_placed in 0..2 {
                if placed == 1 && to_placed == 0 {
                    continue;
                }
                add(encode(i, placed), encode(i, to_placed), &mut mat);
            }
            add(encode(i, placed), encode(i+1, 0), &mut mat);
        }
    }
    add(encode(10, 0), encode(10, 0), &mut mat);

    let mut ans = vec![0; n];
    let mut a = a.into_iter().zip(0..n).collect::<Vec<_>>();
    a.sort();

    let mut last_size = 0;
    let mut table = eye(MAX_SIZE);

    for (l, idx) in a {
        let mut one = vec![0; MAX_SIZE];
        for phase in 0..=5 {
            one[encode(phase, 0)] = 1;
        }
        if last_size < l {
            table = multiply(&table, &pow(mat.clone(), l-last_size));
            last_size = l;
        }
        ans[idx] = multiply_one(&table, &one)[encode(10, 0)];
    }

    for i in 0..n {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 2168