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

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

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

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

g = A("g")
m = B("m")
k = C("k")
h = D("h")
l = A("l")

g.v = m
g.x = k
g.q = k
g.t = h
m.s = h
k.q = m
k.o = m
k.x = m
k.v = h
h.q = k
h.r = l
h.s = l
h.z = l
l.v = m
l.x = k
l.q = k
l.t = h
assert k.v.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.q: C = None
        self.t: D = None
        self.txt = txt

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

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

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

g = A("g")
m = B("m")
k = C("k")
h = D("h")
l = A("l")

g.v = m
g.x = k
g.q = k
g.t = h
m.s = h
k.q = m
k.o = m
k.x = m
k.v = h
h.q = k
h.r = l
h.s = l
h.z = l
l.v = m
l.x = k
l.q = k
l.t = h
assert k.v.s.v.s.txt == "h"