class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: A = None
        self.w: A = None
        self.r: C = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
i = C("i")
l = D("l")
n = B("n")
b = B("b")
h = A("h")
m = C("m")

j.x = l
j.y = h
j.w = h
j.r = m
f.w = l
f.p = m
i.o = l
i.s = l
i.p = h
l.w = j
n.w = l
n.p = m
b.w = l
b.p = i
h.x = l
h.y = j
h.w = j
h.r = m
m.o = l
m.s = l
m.p = h
assert m.p.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: A = None
        self.w: A = None
        self.r: C = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
i = C("i")
l = D("l")
n = B("n")
b = B("b")
h = A("h")
m = C("m")

j.x = l
j.y = h
j.w = h
j.r = m
f.w = l
f.p = m
i.o = l
i.s = l
i.p = h
l.w = j
n.w = l
n.p = m
b.w = l
b.p = i
h.x = l
h.y = j
h.w = j
h.r = m
m.o = l
m.s = l
m.p = h
assert m.p.y.w.txt == "h"