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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: E = None
        self.t: B = None
        self.u: E = None
        self.z: B = None
        self.r: F = 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.x: D = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.y: E = None
        self.o: B = None
        self.txt = txt

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

h.z = g
h.x = m
c.o = l
c.x = h
l.p = i
m.q = l
m.y = i
m.u = i
m.t = c
m.z = c
m.r = a
i.p = m
a.x = m
a.o = l
a.u = h
g.y = i
g.o = c
assert m.q.p.p.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: G = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: E = None
        self.t: B = None
        self.u: E = None
        self.z: B = None
        self.r: F = 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.x: D = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.y: E = None
        self.o: B = None
        self.txt = txt

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

h.z = g
h.x = m
c.o = l
c.x = h
l.p = i
m.q = l
m.y = i
m.u = i
m.t = c
m.z = c
m.r = a
i.p = m
a.x = m
a.o = l
a.u = h
g.y = i
g.o = c
assert m.q.p.p.q.p.p.txt == "m"