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

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

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

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

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

g.t = e
l.y = b
i.w = a
i.r = d
b.s = k
b.u = l
d.y = n
k.s = n
k.u = d
a.t = e
e.w = g
e.r = d
n.s = k
n.u = d
assert k.u.y.u.y.s.u.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

g.t = e
l.y = b
i.w = a
i.r = d
b.s = k
b.u = l
d.y = n
k.s = n
k.u = d
a.t = e
e.w = g
e.r = d
n.s = k
n.u = d
assert k.u.y.u.y.s.u.y.u.y.txt == "n"