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

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

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

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

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

i.o = b
i.x = g
i.z = c
i.q = h
g.z = b
g.w = h
c.x = i
c.z = i
c.y = h
c.w = a
h.y = g
a.x = i
a.z = i
a.y = h
a.w = c
b.z = g
b.w = h
assert a.z.o.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.z: C = None
        self.q: D = None
        self.txt = txt

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

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

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

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

i.o = b
i.x = g
i.z = c
i.q = h
g.z = b
g.w = h
c.x = i
c.z = i
c.y = h
c.w = a
h.y = g
a.x = i
a.z = i
a.y = h
a.w = c
b.z = g
b.w = h
assert a.z.o.w.y.w.txt == "h"