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

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

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

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

m = A("m")
a = B("a")
c = C("c")
b = D("b")
j = C("j")
h = A("h")
n = A("n")
k = D("k")
e = B("e")

m.u = k
m.o = n
m.r = a
a.t = k
c.t = e
c.z = n
b.w = a
b.r = a
j.t = e
j.z = m
h.u = k
h.o = n
h.r = e
n.u = b
n.o = h
n.r = a
k.w = a
k.r = e
e.t = k
assert a.t.r.t.w.t.w.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: A = None
        self.r: B = None
        self.txt = txt

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

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

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

m = A("m")
a = B("a")
c = C("c")
b = D("b")
j = C("j")
h = A("h")
n = A("n")
k = D("k")
e = B("e")

m.u = k
m.o = n
m.r = a
a.t = k
c.t = e
c.z = n
b.w = a
b.r = a
j.t = e
j.z = m
h.u = k
h.o = n
h.r = e
n.u = b
n.o = h
n.r = a
k.w = a
k.r = e
e.t = k
assert a.t.r.t.w.t.w.t.w.t.txt == "k"