answered 10 years ago
Maybe you can try to use the Zmod rings instead of the mod function?
sage: ring_q = Zmod(691) # defining the ring of integers modulo 691 sage: ring_q(345543423) # converting an integer to this ring 581