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

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

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

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

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

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

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

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

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

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

a.s = e
a.y = g
a.w = g
a.x = l
f.v = m
d.p = e
l.o = e
m.v = f
e.p = d
g.s = d
g.y = a
g.w = a
g.x = n
c.o = e
n.o = d
assert c.o.p.p.txt == "e"