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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
m = C("m")
e = D("e")

h.o = k
h.v = k
k.w = m
k.v = e
k.y = e
m.y = k
m.z = k
m.q = k
e.w = k
e.o = k
e.u = h
e.s = h
assert e.w.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
m = C("m")
e = D("e")

h.o = k
h.v = k
k.w = m
k.v = e
k.y = e
m.y = k
m.z = k
m.q = k
e.w = k
e.o = k
e.u = h
e.s = h
assert e.w.v.u.txt == "h"