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

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

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

e = A("e")
f = B("f")
i = C("i")
n = A("n")
g = C("g")

e.q = n
e.t = f
f.r = n
i.o = g
i.z = g
i.x = f
n.q = e
n.t = f
g.o = i
g.z = i
g.x = f
assert e.t.r.t.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
i = C("i")
n = A("n")
g = C("g")

e.q = n
e.t = f
f.r = n
i.o = g
i.z = g
i.x = f
n.q = e
n.t = f
g.o = i
g.z = i
g.x = f
assert e.t.r.t.r.q.txt == "e"