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

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

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

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

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

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

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

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

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

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

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