Groebner bases and distance of cyclic codes