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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: E = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
a = C("a")
j = D("j")
n = E("n")
h = B("h")

d.t = j
m.p = h
m.y = n
m.s = a
m.u = a
a.s = n
j.z = h
j.t = a
n.o = d
n.z = j
h.p = m
h.y = n
h.s = a
h.u = a
assert j.t.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: E = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
a = C("a")
j = D("j")
n = E("n")
h = B("h")

d.t = j
m.p = h
m.y = n
m.s = a
m.u = a
a.s = n
j.z = h
j.t = a
n.o = d
n.z = j
h.p = m
h.y = n
h.s = a
h.u = a
assert j.t.s.z.txt == "j"