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

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

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

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

h = A("h")
j = B("j")
e = C("e")
a = D("a")

h.o = j
h.p = j
h.v = a
h.s = e
j.r = e
j.o = a
e.u = h
e.s = h
e.o = a
e.v = a
a.z = h
a.u = e
assert a.u.s.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.v: D = None
        self.s: C = None
        self.txt = txt

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

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

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

h = A("h")
j = B("j")
e = C("e")
a = D("a")

h.o = j
h.p = j
h.v = a
h.s = e
j.r = e
j.o = a
e.u = h
e.s = h
e.o = a
e.v = a
a.z = h
a.u = e
assert a.u.s.p.o.txt == "a"