Akm[k_,m_]:=Piecewise[{{A[0, 0], k == 0 && m == 0}, {0, (k != 2 && k != 4 && k != 6) || (k != 4 && k != 6 && m != -2 && m != -1 && m != 0 && m != 1 && m != 2) || (k != 6 && m != -4 && m != -3 && m != -2 && m != -1 && m != 0 && m != 1 && m != 2 && m != 3 && m != 4) || (m != -6 && m != -5 && m != -4 && m != -3 && m != -2 && m != -1 && m != 0 && m != 1 && m != 2 && m != 3 && m != 4 && m != 5 && m != 6)}, {A[2, 2], k == 2 && (m == -2 || m == 2)}, {I*B[2, 1], k == 2 && (m == -1 || m == 1)}, {A[2, 0], k == 2 && m == 0}, {A[4, 4], k == 4 && (m == -4 || m == 4)}, {I*B[4, 3], k == 4 && (m == -3 || m == 3)}, {A[4, 2], k == 4 && (m == -2 || m == 2)}, {I*B[4, 1], k == 4 && (m == -1 || m == 1)}, {A[4, 0], k == 4 && m == 0}, {A[6, 6], k == 6 && (m == -6 || m == 6)}, {I*B[6, 5], k == 6 && (m == -5 || m == 5)}, {A[6, 4], k == 6 && (m == -4 || m == 4)}, {I*B[6, 3], k == 6 && (m == -3 || m == 3)}, {A[6, 2], k == 6 && (m == -2 || m == 2)}, {I*B[6, 1], k == 6 && (m == -1 || m == 1)}}, A[6, 0]]