We have, (cos(π3))2+(cos(π4))2+(cos(γ))2=1⇒cos2γ=14
⇒cosγ=±12⇒γ=π3 or 2π3
If the line makes angle π6 and π3 with positive direction of x and y axes respectively, then it makes with z-axis is