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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

m.q = a
m.o = a
a.q = l
a.r = n
n.y = c
n.v = m
g.v = n
g.q = l
k.v = a
l.p = a
l.w = a
l.s = g
l.r = m
f.z = m
d.z = m
c.z = m
assert l.r.o.r.y.z.q.q.s.q.txt == "l"