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

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

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

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

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

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

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

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

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

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

b.u = n
k.y = g
g.q = i
i.s = k
i.u = a
e.u = k
a.u = n
m.s = k
m.u = b
n.y = g
assert k.y.q.s.y.q.u.u.y.txt == "g"