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

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

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

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

h = A("h")
g = B("g")
m = C("m")
l = D("l")

h.w = l
h.o = l
g.z = h
g.x = h
g.u = l
g.q = m
m.w = h
m.o = l
l.s = h
l.v = m
l.x = g
assert h.w.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.o: D = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
m = C("m")
l = D("l")

h.w = l
h.o = l
g.z = h
g.x = h
g.u = l
g.q = m
m.w = h
m.o = l
l.s = h
l.v = m
l.x = g
assert h.w.v.o.txt == "l"