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

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

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

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

d = A("d")
k = B("k")
f = C("f")
g = D("g")

d.w = f
d.t = k
k.p = f
k.y = d
f.q = d
g.s = f
g.u = f
g.r = k
assert d.t.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: B = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
f = C("f")
g = D("g")

d.w = f
d.t = k
k.p = f
k.y = d
f.q = d
g.s = f
g.u = f
g.r = k
assert d.t.y.w.txt == "f"