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

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

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

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

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

b.t = m
b.q = m
b.r = j
k.v = b
k.t = b
k.w = j
k.x = j
m.q = j
m.s = j
m.w = j
j.t = k
assert m.w.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

b.t = m
b.q = m
b.r = j
k.v = b
k.t = b
k.w = j
k.x = j
m.q = j
m.s = j
m.w = j
j.t = k
assert m.w.t.v.txt == "b"