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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: E = None
        self.u: D = None
        self.q: E = None
        self.txt = txt

g = A("g")
i = B("i")
h = C("h")
j = D("j")
f = E("f")
n = F("n")
c = E("c")
a = F("a")

g.s = n
g.r = a
i.r = j
i.w = j
h.v = g
j.s = g
f.z = i
f.r = n
n.s = h
n.v = c
n.u = j
n.q = f
c.z = i
c.r = n
a.s = h
a.v = c
a.u = j
a.q = f
assert a.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.r: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: E = None
        self.u: D = None
        self.q: E = None
        self.txt = txt

g = A("g")
i = B("i")
h = C("h")
j = D("j")
f = E("f")
n = F("n")
c = E("c")
a = F("a")

g.s = n
g.r = a
i.r = j
i.w = j
h.v = g
j.s = g
f.z = i
f.r = n
n.s = h
n.v = c
n.u = j
n.q = f
c.z = i
c.r = n
a.s = h
a.v = c
a.u = j
a.q = f
assert a.s.v.s.txt == "n"