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

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

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

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

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

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

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

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

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

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

n.o = j
n.p = j
d.o = k
d.u = k
d.r = m
d.y = b
a.r = d
a.z = b
a.x = f
a.y = j
j.w = b
b.w = j
m.r = d
m.z = j
m.y = j
m.x = f
k.o = d
k.u = d
k.r = a
k.y = b
f.o = b
f.p = j
assert j.w.w.w.w.txt == "j"