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

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

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

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

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

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

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

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

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

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

n.z = g
n.o = i
n.x = i
n.w = j
b.u = g
b.o = j
b.r = n
m.q = h
g.q = n
g.w = j
g.z = j
h.q = m
i.q = n
i.w = b
i.z = j
j.u = i
j.o = b
j.r = n
assert m.q.q.q.q.txt == "m"