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

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

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

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

d = A("d")
e = B("e")
a = C("a")
i = D("i")
c = C("c")
l = C("l")
f = B("f")
m = A("m")

d.r = c
d.z = c
d.x = m
e.o = f
e.t = a
e.z = c
a.p = m
a.z = e
i.q = a
c.p = d
c.z = f
l.p = m
l.z = f
f.o = e
f.t = l
f.z = l
m.r = l
m.z = l
m.x = d
assert i.q.p.r.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: A = None
        self.z: C = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
a = C("a")
i = D("i")
c = C("c")
l = C("l")
f = B("f")
m = A("m")

d.r = c
d.z = c
d.x = m
e.o = f
e.t = a
e.z = c
a.p = m
a.z = e
i.q = a
c.p = d
c.z = f
l.p = m
l.z = f
f.o = e
f.t = l
f.z = l
m.r = l
m.z = l
m.x = d
assert i.q.p.r.z.t.z.txt == "f"