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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: A = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

b = A("b")
m = B("m")
d = C("d")
h = D("h")
l = E("l")
g = F("g")
k = G("k")

b.q = d
b.x = m
b.s = m
b.z = h
m.t = d
m.w = b
m.x = g
d.z = m
h.s = m
h.v = l
h.o = g
h.z = g
l.o = g
l.r = g
l.y = g
l.p = h
l.w = h
l.t = d
l.x = d
g.r = d
k.p = b
k.x = l
assert k.p.q.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: B = None
        self.z: D = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: A = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

b = A("b")
m = B("m")
d = C("d")
h = D("h")
l = E("l")
g = F("g")
k = G("k")

b.q = d
b.x = m
b.s = m
b.z = h
m.t = d
m.w = b
m.x = g
d.z = m
h.s = m
h.v = l
h.o = g
h.z = g
l.o = g
l.r = g
l.y = g
l.p = h
l.w = h
l.t = d
l.x = d
g.r = d
k.p = b
k.x = l
assert k.p.q.z.x.txt == "g"