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

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

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

class D:
    def __init__(self, txt: str):
        self.u: G = None
        self.z: A = None
        self.r: E = None
        self.w: A = None
        self.t: G = None
        self.q: A = None
        self.p: B = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
i = C("i")
g = D("g")
m = E("m")
e = F("e")
k = G("k")

a.q = m
a.x = l
l.s = e
l.r = k
i.w = g
g.u = k
g.t = k
g.z = a
g.w = a
g.q = a
g.r = m
g.p = l
m.v = a
m.z = e
e.x = a
e.o = m
e.p = g
k.z = g
assert k.z.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: G = None
        self.z: A = None
        self.r: E = None
        self.w: A = None
        self.t: G = None
        self.q: A = None
        self.p: B = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
i = C("i")
g = D("g")
m = E("m")
e = F("e")
k = G("k")

a.q = m
a.x = l
l.s = e
l.r = k
i.w = g
g.u = k
g.t = k
g.z = a
g.w = a
g.q = a
g.r = m
g.p = l
m.v = a
m.z = e
e.x = a
e.o = m
e.p = g
k.z = g
assert k.z.p.r.txt == "k"