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

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

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

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

h = A("h")
b = B("b")
d = C("d")
l = D("l")
k = B("k")

h.v = l
b.r = k
b.w = l
b.z = l
b.s = h
d.s = h
d.o = h
l.y = h
l.w = h
l.x = d
k.r = b
k.w = l
k.z = l
k.s = h
assert h.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
d = C("d")
l = D("l")
k = B("k")

h.v = l
b.r = k
b.w = l
b.z = l
b.s = h
d.s = h
d.o = h
l.y = h
l.w = h
l.x = d
k.r = b
k.w = l
k.z = l
k.s = h
assert h.v.y.v.txt == "l"