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

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

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

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

b = A("b")
m = B("m")
h = C("h")
j = D("j")
g = D("g")
a = C("a")

b.x = m
m.q = a
m.o = b
m.v = j
h.s = m
j.o = a
j.z = h
j.v = g
g.o = a
g.z = h
g.v = j
a.s = m
assert m.v.z.s.o.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
h = C("h")
j = D("j")
g = D("g")
a = C("a")

b.x = m
m.q = a
m.o = b
m.v = j
h.s = m
j.o = a
j.z = h
j.v = g
g.o = a
g.z = h
g.v = j
a.s = m
assert m.v.z.s.o.x.v.txt == "j"