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

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

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

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

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

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

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

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

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

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

l.v = f
l.w = n
g.w = e
d.p = n
d.s = l
e.o = d
e.p = f
k.w = n
a.w = n
f.o = d
f.p = e
n.o = d
n.p = e
assert g.w.p.o.s.w.o.txt == "d"