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

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

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

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

h = A("h")
c = B("c")
f = C("f")
j = D("j")

h.x = f
h.o = f
h.v = j
c.x = f
f.y = h
f.w = h
f.u = c
j.w = c
assert c.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: D = None
        self.o: C = None
        self.txt = txt

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

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

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

h = A("h")
c = B("c")
f = C("f")
j = D("j")

h.x = f
h.o = f
h.v = j
c.x = f
f.y = h
f.w = h
f.u = c
j.w = c
assert c.x.u.x.txt == "f"