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

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

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

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

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

m.s = k
k.v = m
k.u = c
k.q = g
c.y = f
f.v = m
f.x = m
g.v = m
g.x = m
assert f.v.s.u.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

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

m.s = k
k.v = m
k.u = c
k.q = g
c.y = f
f.v = m
f.x = m
g.v = m
g.x = m
assert f.v.s.u.y.x.txt == "m"