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

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

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

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

a = A("a")
m = B("m")
j = C("j")
e = D("e")
b = B("b")

a.z = m
a.y = b
a.s = j
m.t = j
m.r = a
j.o = a
j.z = b
j.u = e
j.x = e
e.r = a
b.t = j
b.r = a
assert a.z.r.y.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.s: C = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
j = C("j")
e = D("e")
b = B("b")

a.z = m
a.y = b
a.s = j
m.t = j
m.r = a
j.o = a
j.z = b
j.u = e
j.x = e
e.r = a
b.t = j
b.r = a
assert a.z.r.y.r.z.txt == "m"