class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

k = A("k")
a = B("a")
c = C("c")
j = C("j")

k.t = j
a.o = j
a.s = k
c.x = a
c.q = k
c.r = j
j.x = a
j.q = k
j.r = c
assert c.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

k = A("k")
a = B("a")
c = C("c")
j = C("j")

k.t = j
a.o = j
a.s = k
c.x = a
c.q = k
c.r = j
j.x = a
j.q = k
j.r = c
assert c.r.r.q.txt == "k"