#include <stdio.h> int cal_sum(int n){ int sum=0; while (n>9){ sum+=n%10; n=n/10; } sum+=n; return sum; } int main(){ int n,num; if (scanf("%d",&n)!=EOF){ for (int i=0;i<n;i++){ if (scanf("%d",&num)!=EOF){ int init_num = cal_sum(num); int result=1; for (int j=2;j<=9;j++){ if (init_num!=cal_sum(num*j)){result=0;} } if (result){printf("%d\n",init_num);} else{printf("NO\n");} } } } return 0; }