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

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: A = None
        self.z: A = None
        self.txt = txt

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

b.y = n
i.u = m
i.y = e
i.s = b
i.w = g
k.y = n
n.w = e
n.p = g
n.z = g
g.y = n
m.u = i
m.y = k
m.s = b
m.w = b
e.y = n
assert k.y.p.y.z.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: A = None
        self.z: A = None
        self.txt = txt

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

b.y = n
i.u = m
i.y = e
i.s = b
i.w = g
k.y = n
n.w = e
n.p = g
n.z = g
g.y = n
m.u = i
m.y = k
m.s = b
m.w = b
e.y = n
assert k.y.p.y.z.y.w.y.txt == "n"