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

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

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

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

k = A("k")
h = B("h")
f = C("f")
c = D("c")

k.x = f
h.w = k
h.o = k
h.u = c
f.z = c
f.x = h
f.v = k
c.u = f
c.v = f
c.x = k
c.z = k
assert f.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

k = A("k")
h = B("h")
f = C("f")
c = D("c")

k.x = f
h.w = k
h.o = k
h.u = c
f.z = c
f.x = h
f.v = k
c.u = f
c.v = f
c.x = k
c.z = k
assert f.x.u.x.txt == "k"