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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

b.q = m
b.v = c
b.r = g
i.q = n
i.s = g
i.x = m
i.r = m
i.z = c
a.w = g
a.r = g
n.y = m
n.p = b
f.y = n
f.q = m
f.x = i
g.w = i
g.s = n
g.y = a
m.o = f
h.q = m
h.v = c
h.r = g
c.q = m
c.v = b
c.r = g
assert a.r.w.s.w.s.w.s.txt == "g"