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

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

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

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

h = A("h")
i = B("i")
m = C("m")
a = D("a")
k = A("k")
j = B("j")

h.w = k
h.o = k
h.x = a
h.z = i
i.u = a
i.y = k
i.r = h
m.r = a
m.z = a
m.q = a
m.y = k
a.r = i
a.y = m
a.p = k
a.x = j
k.w = h
k.o = h
k.x = a
k.z = j
j.u = a
j.y = k
j.r = k
assert h.o.o.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: D = None
        self.z: B = None
        self.o: A = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
m = C("m")
a = D("a")
k = A("k")
j = B("j")

h.w = k
h.o = k
h.x = a
h.z = i
i.u = a
i.y = k
i.r = h
m.r = a
m.z = a
m.q = a
m.y = k
a.r = i
a.y = m
a.p = k
a.x = j
k.w = h
k.o = h
k.x = a
k.z = j
j.u = a
j.y = k
j.r = k
assert h.o.o.o.z.txt == "j"