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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.t: C = None
        self.o: D = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
d = C("d")
j = D("j")
l = E("l")
i = D("i")
h = C("h")

m.x = k
m.s = i
k.t = m
k.s = h
d.p = l
d.t = h
d.o = i
j.x = k
j.q = h
j.z = i
l.t = k
l.y = d
i.x = k
i.q = h
i.z = j
h.p = l
h.t = d
h.o = j
assert m.x.t.s.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.t: C = None
        self.o: D = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
d = C("d")
j = D("j")
l = E("l")
i = D("i")
h = C("h")

m.x = k
m.s = i
k.t = m
k.s = h
d.p = l
d.t = h
d.o = i
j.x = k
j.q = h
j.z = i
l.t = k
l.y = d
i.x = k
i.q = h
i.z = j
h.p = l
h.t = d
h.o = j
assert m.x.t.s.x.t.s.txt == "i"