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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: C = None
        self.txt = txt

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

g.q = h
g.o = f
g.s = l
g.x = n
n.x = f
c.o = h
c.w = m
c.u = m
h.v = m
h.u = c
m.q = h
m.o = c
m.s = l
m.x = l
f.o = h
f.w = m
f.u = g
l.x = c
assert c.u.q.u.u.o.w.txt == "m"