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

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

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

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

g = A("g")
c = B("c")
m = C("m")
a = D("a")
n = D("n")
d = C("d")

g.p = c
g.o = c
g.t = c
g.v = a
c.v = n
m.o = d
a.s = n
n.s = a
d.o = m
assert c.v.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.o: B = None
        self.t: B = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
m = C("m")
a = D("a")
n = D("n")
d = C("d")

g.p = c
g.o = c
g.t = c
g.v = a
c.v = n
m.o = d
a.s = n
n.s = a
d.o = m
assert c.v.s.s.s.s.txt == "n"