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

class B:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: B = None
        self.w: E = None
        self.u: A = None
        self.q: C = None
        self.s: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: F = None
        self.t: C = None
        self.v: B = None
        self.z: D = None
        self.txt = txt

n = A("n")
c = B("c")
h = C("h")
k = D("k")
l = E("l")
m = F("m")
i = G("i")
g = D("g")

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

class B:
    def __init__(self, txt: str):
        self.p: G = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: B = None
        self.w: E = None
        self.u: A = None
        self.q: C = None
        self.s: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: F = None
        self.t: C = None
        self.v: B = None
        self.z: D = None
        self.txt = txt

n = A("n")
c = B("c")
h = C("h")
k = D("k")
l = E("l")
m = F("m")
i = G("i")
g = D("g")

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