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

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

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

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

h = A("h")
a = B("a")
l = C("l")
f = D("f")

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

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

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

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

h = A("h")
a = B("a")
l = C("l")
f = D("f")

h.o = a
h.r = a
h.z = f
h.v = l
a.o = l
l.u = a
l.z = f
l.p = h
f.v = a
f.w = h
assert h.o.o.p.txt == "h"