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

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

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

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

b = A("b")
e = B("e")
f = C("f")
k = D("k")

b.v = e
b.t = f
e.w = b
f.y = b
k.w = f
k.t = f
k.x = b
assert e.w.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: C = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
f = C("f")
k = D("k")

b.v = e
b.t = f
e.w = b
f.y = b
k.w = f
k.t = f
k.x = b
assert e.w.t.y.txt == "b"