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

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

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

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

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

k.q = j
k.u = m
j.t = k
j.s = k
j.u = i
m.v = i
i.p = m
i.z = k
i.t = j
assert m.v.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.txt = txt

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

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

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

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

k.q = j
k.u = m
j.t = k
j.s = k
j.u = i
m.v = i
i.p = m
i.z = k
i.t = j
assert m.v.t.s.txt == "k"