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

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

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

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

d = A("d")
m = B("m")
i = C("i")
n = D("n")
a = C("a")
f = C("f")
h = D("h")
j = D("j")

d.p = m
m.v = a
m.s = h
i.w = n
i.y = h
i.q = m
n.y = j
a.w = j
a.y = h
a.q = m
f.w = h
f.y = j
f.q = m
h.y = n
j.y = n
assert j.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

d = A("d")
m = B("m")
i = C("i")
n = D("n")
a = C("a")
f = C("f")
h = D("h")
j = D("j")

d.p = m
m.v = a
m.s = h
i.w = n
i.y = h
i.q = m
n.y = j
a.w = j
a.y = h
a.q = m
f.w = h
f.y = j
f.q = m
h.y = n
j.y = n
assert j.y.y.y.y.txt == "j"