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

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

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

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

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

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

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

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

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

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

d.z = c
d.p = l
h.o = m
h.x = d
n.o = e
n.u = f
n.w = h
e.r = h
e.y = h
e.o = c
e.u = c
c.r = m
c.y = h
c.o = e
c.u = e
k.o = f
k.u = c
k.w = m
l.z = f
l.p = d
m.o = h
m.x = d
f.r = m
f.y = m
f.o = e
f.u = c
assert n.o.u.r.o.x.p.txt == "l"