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

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

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

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

a = A("a")
f = B("f")
b = C("b")
c = D("c")

a.v = b
f.t = c
f.u = c
b.x = f
c.z = a
assert a.v.x.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
b = C("b")
c = D("c")

a.v = b
f.t = c
f.u = c
b.x = f
c.z = a
assert a.v.x.t.z.txt == "a"