class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.p: G = None
        self.o: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.x: G = None
        self.p: E = None
        self.q: E = None
        self.w: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.w: A = 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.u: E = None
        self.x: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: B = None
        self.r: F = None
        self.q: A = None
        self.v: C = None
        self.txt = txt

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

a.r = e
a.p = e
a.o = m
f.v = e
f.x = e
f.p = l
f.q = l
f.w = l
h.y = g
g.p = l
g.w = d
l.p = g
m.u = l
m.x = e
e.t = a
e.u = f
e.r = m
e.q = d
e.v = h
d.r = e
d.p = e
d.o = m
n.r = e
n.p = e
n.o = m
assert g.p.p.w.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.p: G = None
        self.o: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.x: G = None
        self.p: E = None
        self.q: E = None
        self.w: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.w: A = 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.u: E = None
        self.x: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: B = None
        self.r: F = None
        self.q: A = None
        self.v: C = None
        self.txt = txt

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

a.r = e
a.p = e
a.o = m
f.v = e
f.x = e
f.p = l
f.q = l
f.w = l
h.y = g
g.p = l
g.w = d
l.p = g
m.u = l
m.x = e
e.t = a
e.u = f
e.r = m
e.q = d
e.v = h
d.r = e
d.p = e
d.o = m
n.r = e
n.p = e
n.o = m
assert g.p.p.w.p.t.txt == "a"