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

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

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

a = A("a")
h = B("h")
e = C("e")
g = A("g")
i = C("i")

a.t = h
h.z = e
h.v = e
h.x = a
e.u = i
e.q = i
e.x = i
g.t = h
i.u = e
i.q = e
i.x = e
assert e.q.q.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
e = C("e")
g = A("g")
i = C("i")

a.t = h
h.z = e
h.v = e
h.x = a
e.u = i
e.q = i
e.x = i
g.t = h
i.u = e
i.q = e
i.x = e
assert e.q.q.x.x.q.txt == "i"