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

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

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

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

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

g = A("g")
h = B("h")
d = C("d")
l = D("l")
n = E("n")
k = A("k")
f = A("f")
c = B("c")
m = C("m")

g.t = l
g.x = l
g.y = n
g.r = n
h.p = n
d.o = m
d.u = c
l.p = f
l.x = h
n.x = m
k.t = l
k.x = l
k.y = n
k.r = n
f.t = l
f.x = l
f.y = n
f.r = n
c.p = n
m.o = d
m.u = c
assert m.u.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: E = None
        self.x: D = None
        self.r: E = None
        self.txt = txt

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

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

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

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

g = A("g")
h = B("h")
d = C("d")
l = D("l")
n = E("n")
k = A("k")
f = A("f")
c = B("c")
m = C("m")

g.t = l
g.x = l
g.y = n
g.r = n
h.p = n
d.o = m
d.u = c
l.p = f
l.x = h
n.x = m
k.t = l
k.x = l
k.y = n
k.r = n
f.t = l
f.x = l
f.y = n
f.r = n
c.p = n
m.o = d
m.u = c
assert m.u.p.x.txt == "m"