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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: A = None
        self.p: A = None
        self.w: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: F = None
        self.u: F = None
        self.x: G = None
        self.v: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: A = None
        self.txt = txt

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

j.r = i
j.v = i
h.s = j
h.u = j
h.p = j
h.w = i
a.r = h
c.q = a
c.p = g
c.u = n
c.x = i
c.v = i
b.r = a
g.o = h
g.q = e
g.r = f
g.v = a
g.x = b
i.x = f
i.r = j
n.o = h
n.q = e
n.r = f
n.v = a
n.x = b
e.q = a
e.p = n
e.u = g
e.x = i
e.v = i
f.r = a
assert f.r.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.v: G = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: A = None
        self.p: A = None
        self.w: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: F = None
        self.u: F = None
        self.x: G = None
        self.v: G = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: A = None
        self.txt = txt

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

j.r = i
j.v = i
h.s = j
h.u = j
h.p = j
h.w = i
a.r = h
c.q = a
c.p = g
c.u = n
c.x = i
c.v = i
b.r = a
g.o = h
g.q = e
g.r = f
g.v = a
g.x = b
i.x = f
i.r = j
n.o = h
n.q = e
n.r = f
n.v = a
n.x = b
e.q = a
e.p = n
e.u = g
e.x = i
e.v = i
f.r = a
assert f.r.r.u.txt == "j"