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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.t: G = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: E = None
        self.u: D = None
        self.s: G = None
        self.p: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: A = None
        self.q: B = None
        self.y: D = None
        self.z: G = None
        self.txt = txt

b = A("b")
g = B("g")
i = C("i")
f = D("f")
e = E("e")
m = F("m")
j = G("j")
k = G("k")
n = B("n")

b.p = j
b.q = g
g.s = n
i.w = e
i.t = k
f.s = j
f.o = m
e.r = m
e.v = g
e.z = b
e.x = f
m.r = b
m.o = e
m.u = f
m.s = j
m.p = i
j.x = g
j.r = b
j.q = n
j.y = f
j.z = k
k.x = n
k.r = b
k.q = g
k.y = f
k.z = j
n.s = g
assert b.q.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: G = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.t: G = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: E = None
        self.u: D = None
        self.s: G = None
        self.p: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: A = None
        self.q: B = None
        self.y: D = None
        self.z: G = None
        self.txt = txt

b = A("b")
g = B("g")
i = C("i")
f = D("f")
e = E("e")
m = F("m")
j = G("j")
k = G("k")
n = B("n")

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