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

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

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

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

m = A("m")
g = B("g")
i = C("i")
l = D("l")
c = B("c")
k = B("k")
f = D("f")

m.s = i
g.o = l
g.z = m
g.q = i
i.z = k
l.z = i
l.o = i
l.x = k
l.v = k
c.o = f
c.z = m
c.q = i
k.o = l
k.z = m
k.q = i
f.z = i
f.o = i
f.x = k
f.v = k
assert m.s.z.o.x.o.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
i = C("i")
l = D("l")
c = B("c")
k = B("k")
f = D("f")

m.s = i
g.o = l
g.z = m
g.q = i
i.z = k
l.z = i
l.o = i
l.x = k
l.v = k
c.o = f
c.z = m
c.q = i
k.o = l
k.z = m
k.q = i
f.z = i
f.o = i
f.x = k
f.v = k
assert m.s.z.o.x.o.x.z.txt == "m"