class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.x: C = None
        self.v: C = None
        self.txt = txt

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

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

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

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

f.o = c
f.z = a
f.x = a
f.v = a
b.o = j
j.x = n
j.o = k
e.w = n
a.x = b
a.o = k
g.w = c
k.w = c
c.o = a
n.o = j
i.w = n
assert k.w.o.x.o.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.x: C = None
        self.v: C = None
        self.txt = txt

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

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

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

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

f.o = c
f.z = a
f.x = a
f.v = a
b.o = j
j.x = n
j.o = k
e.w = n
a.x = b
a.o = k
g.w = c
k.w = c
c.o = a
n.o = j
i.w = n
assert k.w.o.x.o.o.w.txt == "c"