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

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

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

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

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

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

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

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

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

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

m.x = i
i.s = m
i.x = m
k.z = f
k.q = c
k.t = c
f.u = m
f.t = k
c.z = f
c.q = g
c.t = g
g.z = f
g.q = k
g.t = c
assert f.u.x.x.x.x.txt == "m"