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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.v: F = None
        self.t: A = None
        self.p: G = None
        self.x: A = None
        self.o: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: D = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.v: F = None
        self.t: A = None
        self.p: G = None
        self.x: A = None
        self.o: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: D = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

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

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

g.q = h
g.r = h
g.p = f
h.r = c
m.v = k
m.r = g
k.y = f
k.s = f
c.y = m
c.q = m
c.v = f
c.t = g
c.x = g
c.p = a
c.o = a
f.u = g
f.q = g
f.w = k
f.p = m
a.p = f
a.r = c
a.o = m
a.x = m
a.q = k
assert a.o.r.p.u.r.r.q.txt == "m"