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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.p: B = None
        self.s: B = None
        self.txt = txt

f = A("f")
m = B("m")
b = C("b")
i = D("i")
h = E("h")
n = C("n")
l = C("l")
k = D("k")
e = C("e")
d = D("d")

f.o = i
f.y = i
m.z = n
m.x = n
b.y = m
b.p = m
i.p = n
h.o = m
h.x = m
h.p = m
h.s = m
n.y = m
n.p = m
l.y = m
l.p = m
k.p = l
e.y = m
e.p = m
d.p = l
assert i.p.y.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.p: B = None
        self.s: B = None
        self.txt = txt

f = A("f")
m = B("m")
b = C("b")
i = D("i")
h = E("h")
n = C("n")
l = C("l")
k = D("k")
e = C("e")
d = D("d")

f.o = i
f.y = i
m.z = n
m.x = n
b.y = m
b.p = m
i.p = n
h.o = m
h.x = m
h.p = m
h.s = m
n.y = m
n.p = m
l.y = m
l.p = m
k.p = l
e.y = m
e.p = m
d.p = l
assert i.p.y.x.p.txt == "m"