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

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

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

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

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

d.u = b
d.s = i
d.y = k
d.o = h
e.o = b
e.u = i
e.z = a
n.q = h
a.r = m
k.u = e
k.s = e
k.y = d
k.o = n
h.q = n
i.o = b
i.u = e
i.z = m
b.o = e
b.u = e
b.z = m
m.r = a
assert a.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: B = None
        self.y: A = None
        self.o: C = None
        self.txt = txt

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

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

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

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

d.u = b
d.s = i
d.y = k
d.o = h
e.o = b
e.u = i
e.z = a
n.q = h
a.r = m
k.u = e
k.s = e
k.y = d
k.o = n
h.q = n
i.o = b
i.u = e
i.z = m
b.o = e
b.u = e
b.z = m
m.r = a
assert a.r.r.r.r.txt == "a"