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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

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