class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: C = None
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

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

n.q = g
h.o = g
h.v = b
a.u = b
a.v = b
a.z = g
a.s = g
a.y = j
j.p = a
j.r = i
g.y = n
g.t = a
g.r = e
g.v = h
b.s = i
e.q = g
i.s = b
assert j.r.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: C = None
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

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

n.q = g
h.o = g
h.v = b
a.u = b
a.v = b
a.z = g
a.s = g
a.y = j
j.p = a
j.r = i
g.y = n
g.t = a
g.r = e
g.v = h
b.s = i
e.q = g
i.s = b
assert j.r.s.s.s.s.s.s.txt == "i"