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

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

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

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

n = A("n")
j = B("j")
m = C("m")
k = D("k")
g = C("g")
a = C("a")
i = B("i")
d = D("d")
f = C("f")
b = D("b")

n.w = m
n.u = i
j.p = d
j.t = i
m.q = n
m.r = b
k.u = b
k.p = b
g.q = n
g.r = k
a.q = n
a.r = b
i.p = b
i.t = j
d.u = k
d.p = b
f.q = n
f.r = d
b.u = d
b.p = k
assert k.p.u.p.u.p.u.u.p.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: B = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
m = C("m")
k = D("k")
g = C("g")
a = C("a")
i = B("i")
d = D("d")
f = C("f")
b = D("b")

n.w = m
n.u = i
j.p = d
j.t = i
m.q = n
m.r = b
k.u = b
k.p = b
g.q = n
g.r = k
a.q = n
a.r = b
i.p = b
i.t = j
d.u = k
d.p = b
f.q = n
f.r = d
b.u = d
b.p = k
assert k.p.u.p.u.p.u.u.p.u.p.txt == "b"