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

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

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

j = A("j")
m = B("m")
d = C("d")
i = A("i")
k = C("k")
h = B("h")

j.t = k
j.x = d
m.t = h
m.z = j
m.q = j
d.s = i
d.r = k
d.u = j
i.t = k
i.x = d
k.s = j
k.r = d
k.u = i
h.t = m
h.z = i
h.q = j
assert h.q.t.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

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

j = A("j")
m = B("m")
d = C("d")
i = A("i")
k = C("k")
h = B("h")

j.t = k
j.x = d
m.t = h
m.z = j
m.q = j
d.s = i
d.r = k
d.u = j
i.t = k
i.x = d
k.s = j
k.r = d
k.u = i
h.t = m
h.z = i
h.q = j
assert h.q.t.u.x.txt == "d"