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

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

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

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

j = A("j")
c = B("c")
g = C("g")
k = D("k")
i = A("i")
h = C("h")
m = B("m")

j.v = c
c.s = i
c.u = m
g.w = c
g.z = k
g.q = k
g.x = h
k.p = g
i.v = m
h.w = m
h.z = k
h.q = k
h.x = g
m.s = j
m.u = c
assert i.v.u.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
g = C("g")
k = D("k")
i = A("i")
h = C("h")
m = B("m")

j.v = c
c.s = i
c.u = m
g.w = c
g.z = k
g.q = k
g.x = h
k.p = g
i.v = m
h.w = m
h.z = k
h.q = k
h.x = g
m.s = j
m.u = c
assert i.v.u.s.v.txt == "m"