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

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

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

e = A("e")
j = B("j")
f = C("f")
l = B("l")
m = C("m")
c = B("c")
h = B("h")
i = A("i")

e.q = m
e.p = j
e.t = i
j.z = e
j.w = m
f.x = h
f.t = m
l.z = i
l.w = m
m.x = l
m.t = f
c.z = e
c.w = m
h.z = i
h.w = f
i.q = f
i.p = c
i.t = e
assert j.z.q.t.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: B = None
        self.t: A = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
f = C("f")
l = B("l")
m = C("m")
c = B("c")
h = B("h")
i = A("i")

e.q = m
e.p = j
e.t = i
j.z = e
j.w = m
f.x = h
f.t = m
l.z = i
l.w = m
m.x = l
m.t = f
c.z = e
c.w = m
h.z = i
h.w = f
i.q = f
i.p = c
i.t = e
assert j.z.q.t.x.w.txt == "f"