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

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

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

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

i = A("i")
m = B("m")
g = C("g")
n = D("n")
h = C("h")
c = A("c")

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

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

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

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

i = A("i")
m = B("m")
g = C("g")
n = D("n")
h = C("h")
c = A("c")

i.y = m
i.z = c
i.v = n
m.y = n
m.x = n
m.s = n
m.z = i
g.x = m
g.o = m
g.q = n
g.w = n
n.y = h
n.q = h
h.x = m
h.o = m
h.q = n
h.w = n
c.y = m
c.z = i
c.v = n
assert n.y.w.q.w.q.w.txt == "n"