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

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

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

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

n = A("n")
e = B("e")
h = C("h")
i = D("i")
c = A("c")
f = D("f")
k = C("k")
g = A("g")
l = B("l")

n.u = e
n.w = e
n.x = l
n.q = c
e.r = l
e.o = f
e.q = h
h.r = l
i.w = c
c.u = l
c.x = l
c.q = n
c.w = e
f.w = g
k.r = e
g.u = l
g.x = l
g.q = n
g.w = e
l.r = e
l.o = f
l.q = h
assert f.w.x.r.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: B = None
        self.q: A = None
        self.w: B = None
        self.txt = txt

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

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

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

n = A("n")
e = B("e")
h = C("h")
i = D("i")
c = A("c")
f = D("f")
k = C("k")
g = A("g")
l = B("l")

n.u = e
n.w = e
n.x = l
n.q = c
e.r = l
e.o = f
e.q = h
h.r = l
i.w = c
c.u = l
c.x = l
c.q = n
c.w = e
f.w = g
k.r = e
g.u = l
g.x = l
g.q = n
g.w = e
l.r = e
l.o = f
l.q = h
assert f.w.x.r.o.w.txt == "g"