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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.p: D = None
        self.y: F = None
        self.txt = txt

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

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

e.s = b
e.r = l
e.w = l
n.q = e
n.r = m
n.u = l
n.w = g
l.s = n
l.r = b
b.p = j
b.w = j
b.v = n
b.z = e
g.x = b
g.p = b
g.q = n
g.y = m
j.o = n
j.w = m
j.x = b
m.o = n
m.w = j
m.x = b
assert n.q.r.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: C = None
        self.w: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.p: D = None
        self.y: F = None
        self.txt = txt

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

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

e.s = b
e.r = l
e.w = l
n.q = e
n.r = m
n.u = l
n.w = g
l.s = n
l.r = b
b.p = j
b.w = j
b.v = n
b.z = e
g.x = b
g.p = b
g.q = n
g.y = m
j.o = n
j.w = m
j.x = b
m.o = n
m.w = j
m.x = b
assert n.q.r.s.w.txt == "g"