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

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

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

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

h = A("h")
g = B("g")
i = C("i")
a = D("a")

h.o = a
h.t = a
h.p = g
g.u = h
i.u = g
i.y = g
i.w = h
a.o = i
assert a.o.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: D = None
        self.p: B = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
i = C("i")
a = D("a")

h.o = a
h.t = a
h.p = g
g.u = h
i.u = g
i.y = g
i.w = h
a.o = i
assert a.o.w.t.txt == "a"