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

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

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

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

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

j.w = d
b.w = n
b.q = d
k.z = e
k.r = i
k.p = j
d.o = m
m.o = d
f.z = b
f.r = k
f.p = j
i.z = e
i.r = k
i.p = j
n.o = m
e.w = m
e.q = n
assert j.w.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

j.w = d
b.w = n
b.q = d
k.z = e
k.r = i
k.p = j
d.o = m
m.o = d
f.z = b
f.r = k
f.p = j
i.z = e
i.r = k
i.p = j
n.o = m
e.w = m
e.q = n
assert j.w.o.o.o.txt == "m"