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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: F = None
        self.txt = txt

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

m = A("m")
e = B("e")
n = C("n")
j = D("j")
l = E("l")
f = F("f")
g = F("g")

m.u = g
m.p = n
m.o = e
e.r = g
n.s = j
n.o = m
n.x = g
j.w = g
l.p = j
l.r = g
f.o = g
f.x = e
f.q = n
g.o = f
g.x = e
g.q = n
assert l.p.w.q.s.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.p: C = None
        self.o: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: F = None
        self.txt = txt

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

m = A("m")
e = B("e")
n = C("n")
j = D("j")
l = E("l")
f = F("f")
g = F("g")

m.u = g
m.p = n
m.o = e
e.r = g
n.s = j
n.o = m
n.x = g
j.w = g
l.p = j
l.r = g
f.o = g
f.x = e
f.q = n
g.o = f
g.x = e
g.q = n
assert l.p.w.q.s.w.q.txt == "n"