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

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

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

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

f = A("f")
n = B("n")
k = C("k")
l = D("l")
a = C("a")
b = D("b")
c = D("c")
g = D("g")

f.v = b
n.z = f
k.q = f
k.t = a
l.s = n
l.o = g
l.z = g
a.q = f
a.t = k
b.s = n
b.o = g
b.z = c
c.s = n
c.o = b
c.z = b
g.s = n
g.o = c
g.z = l
assert a.q.v.s.z.v.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
k = C("k")
l = D("l")
a = C("a")
b = D("b")
c = D("c")
g = D("g")

f.v = b
n.z = f
k.q = f
k.t = a
l.s = n
l.o = g
l.z = g
a.q = f
a.t = k
b.s = n
b.o = g
b.z = c
c.s = n
c.o = b
c.z = b
g.s = n
g.o = c
g.z = l
assert a.q.v.s.z.v.z.o.txt == "b"