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

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

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

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

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

m.x = f
m.z = d
e.o = a
e.z = c
a.o = d
a.q = d
a.s = i
a.v = i
d.r = m
d.o = m
d.t = i
d.z = f
k.o = a
k.z = f
f.x = c
f.z = d
i.o = d
i.q = d
i.s = a
i.v = a
b.o = a
b.z = f
c.x = f
c.z = d
assert e.z.x.z.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: D = None
        self.txt = txt

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

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

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

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

m.x = f
m.z = d
e.o = a
e.z = c
a.o = d
a.q = d
a.s = i
a.v = i
d.r = m
d.o = m
d.t = i
d.z = f
k.o = a
k.z = f
f.x = c
f.z = d
i.o = d
i.q = d
i.s = a
i.v = a
b.o = a
b.z = f
c.x = f
c.z = d
assert e.z.x.z.r.x.txt == "f"