class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
h = C("h")
i = D("i")
m = C("m")
l = B("l")
e = D("e")
a = A("a")
f = A("f")

k.q = f
k.w = i
k.u = a
n.y = h
n.s = h
n.x = l
h.x = m
h.s = m
h.u = n
i.q = m
i.r = k
m.x = h
m.s = h
m.u = n
l.y = m
l.s = m
l.x = n
e.q = h
e.r = a
a.q = k
a.u = k
a.w = i
f.q = k
f.w = i
f.u = a
assert a.q.u.u.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
h = C("h")
i = D("i")
m = C("m")
l = B("l")
e = D("e")
a = A("a")
f = A("f")

k.q = f
k.w = i
k.u = a
n.y = h
n.s = h
n.x = l
h.x = m
h.s = m
h.u = n
i.q = m
i.r = k
m.x = h
m.s = h
m.u = n
l.y = m
l.s = m
l.x = n
e.q = h
e.r = a
a.q = k
a.u = k
a.w = i
f.q = k
f.w = i
f.u = a
assert a.q.u.u.q.q.u.txt == "a"