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

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

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

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

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

d.v = k
d.s = e
c.y = f
k.o = l
k.v = c
f.z = c
f.o = c
f.p = g
e.o = l
e.v = c
j.o = l
j.v = c
g.v = e
g.s = j
n.z = c
n.o = c
n.p = g
l.z = c
l.o = c
l.p = d
assert n.z.y.p.s.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: C = None
        self.txt = txt

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

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

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

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

d.v = k
d.s = e
c.y = f
k.o = l
k.v = c
f.z = c
f.o = c
f.p = g
e.o = l
e.v = c
j.o = l
j.v = c
g.v = e
g.s = j
n.z = c
n.o = c
n.p = g
l.z = c
l.o = c
l.p = d
assert n.z.y.p.s.v.y.txt == "f"