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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: C = None
        self.x: B = None
        self.r: C = None
        self.txt = txt

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

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

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

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

m.p = h
l.y = c
l.w = j
l.r = j
l.x = h
j.o = n
j.x = n
c.o = l
a.w = h
a.r = n
n.o = h
h.y = n
h.w = j
h.r = j
h.x = l
assert h.y.o.y.o.y.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: C = None
        self.x: B = None
        self.r: C = None
        self.txt = txt

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

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

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

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

m.p = h
l.y = c
l.w = j
l.r = j
l.x = h
j.o = n
j.x = n
c.o = l
a.w = h
a.r = n
n.o = h
h.y = n
h.w = j
h.r = j
h.x = l
assert h.y.o.y.o.y.o.x.txt == "l"