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

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.r: C = None
        self.v: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

n = A("n")
m = B("m")
j = C("j")
c = D("c")
e = E("e")
k = A("k")

n.t = e
n.w = m
m.y = e
m.r = j
m.v = j
j.s = k
c.t = e
c.x = e
c.s = j
c.y = j
e.z = m
k.t = e
k.w = m
assert j.s.t.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.r: C = None
        self.v: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

n = A("n")
m = B("m")
j = C("j")
c = D("c")
e = E("e")
k = A("k")

n.t = e
n.w = m
m.y = e
m.r = j
m.v = j
j.s = k
c.t = e
c.x = e
c.s = j
c.y = j
e.z = m
k.t = e
k.w = m
assert j.s.t.z.r.txt == "j"