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

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

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

e = A("e")
f = B("f")
j = C("j")
c = B("c")

e.q = f
f.o = j
f.t = e
j.o = e
c.o = j
c.t = e
assert f.o.o.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
j = C("j")
c = B("c")

e.q = f
f.o = j
f.t = e
j.o = e
c.o = j
c.t = e
assert f.o.o.q.t.txt == "e"