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

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

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

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

n = A("n")
d = B("d")
l = C("l")
k = D("k")
m = C("m")
h = A("h")

n.u = l
n.r = h
n.x = h
n.q = d
d.p = m
l.x = k
l.o = m
l.y = h
k.o = l
k.w = l
k.r = d
k.v = m
m.x = k
m.o = l
m.y = n
h.u = l
h.r = n
h.x = n
h.q = d
assert m.y.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: A = None
        self.x: A = None
        self.q: B = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
l = C("l")
k = D("k")
m = C("m")
h = A("h")

n.u = l
n.r = h
n.x = h
n.q = d
d.p = m
l.x = k
l.o = m
l.y = h
k.o = l
k.w = l
k.r = d
k.v = m
m.x = k
m.o = l
m.y = n
h.u = l
h.r = n
h.x = n
h.q = d
assert m.y.u.o.txt == "m"