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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.z: C = None
        self.w: D = None
        self.txt = txt

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

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

a.s = c
a.v = g
m.v = e
m.o = a
m.q = c
e.q = a
e.x = m
e.z = g
e.w = c
c.t = m
c.r = l
l.s = c
l.v = g
n.v = g
n.o = l
n.q = c
g.q = l
g.x = m
g.z = e
g.w = c
assert a.v.q.s.t.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.z: C = None
        self.w: D = None
        self.txt = txt

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

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

a.s = c
a.v = g
m.v = e
m.o = a
m.q = c
e.q = a
e.x = m
e.z = g
e.w = c
c.t = m
c.r = l
l.s = c
l.v = g
n.v = g
n.o = l
n.q = c
g.q = l
g.x = m
g.z = e
g.w = c
assert a.v.q.s.t.q.t.q.txt == "c"