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

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

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

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

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

m.x = k
m.w = k
m.r = g
m.q = i
k.s = i
k.u = i
i.s = k
i.v = g
i.z = g
g.x = m
g.t = m
assert i.z.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: D = None
        self.w: B = None
        self.q: C = None
        self.txt = txt

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

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

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

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

m.x = k
m.w = k
m.r = g
m.q = i
k.s = i
k.u = i
i.s = k
i.v = g
i.z = g
g.x = m
g.t = m
assert i.z.x.r.txt == "g"