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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: A = None
        self.p: D = None
        self.s: E = None
        self.u: B = None
        self.w: A = None
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.y: B = None
        self.x: C = None
        self.t: D = None
        self.s: D = None
        self.txt = txt

a = A("a")
m = B("m")
h = C("h")
b = D("b")
f = E("f")
i = F("i")
e = G("e")
l = A("l")

a.y = e
m.z = b
m.y = l
h.x = a
h.t = a
h.w = a
h.p = b
h.s = f
h.u = m
h.q = m
b.z = h
f.t = l
i.w = a
e.w = f
e.y = m
e.x = h
e.t = b
e.s = b
l.y = e
assert a.y.x.s.t.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: A = None
        self.p: D = None
        self.s: E = None
        self.u: B = None
        self.w: A = None
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.y: B = None
        self.x: C = None
        self.t: D = None
        self.s: D = None
        self.txt = txt

a = A("a")
m = B("m")
h = C("h")
b = D("b")
f = E("f")
i = F("i")
e = G("e")
l = A("l")

a.y = e
m.z = b
m.y = l
h.x = a
h.t = a
h.w = a
h.p = b
h.s = f
h.u = m
h.q = m
b.z = h
f.t = l
i.w = a
e.w = f
e.y = m
e.x = h
e.t = b
e.s = b
l.y = e
assert a.y.x.s.t.y.x.txt == "h"