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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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