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

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

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

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

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

a.v = m
g.t = a
i.o = m
i.t = a
m.o = i
m.w = l
n.t = a
k.o = l
k.t = a
f.t = a
d.t = a
l.o = k
l.w = m
assert l.o.t.v.o.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

a.v = m
g.t = a
i.o = m
i.t = a
m.o = i
m.w = l
n.t = a
k.o = l
k.t = a
f.t = a
d.t = a
l.o = k
l.w = m
assert l.o.t.v.o.o.w.o.txt == "k"