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

class B:
    def __init__(self, txt: str):
        self.v: H = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: H = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: H = None
        self.q: F = None
        self.o: H = None
        self.t: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: H = None
        self.x: G = None
        self.t: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: B = None
        self.p: E = None
        self.x: C = None
        self.q: H = None
        self.t: D = None
        self.w: C = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

g = A("g")
c = B("c")
d = C("d")
k = D("k")
n = E("n")
l = F("l")
h = G("h")
e = H("e")

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

class B:
    def __init__(self, txt: str):
        self.v: H = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: H = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: H = None
        self.q: F = None
        self.o: H = None
        self.t: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: H = None
        self.x: G = None
        self.t: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: B = None
        self.p: E = None
        self.x: C = None
        self.q: H = None
        self.t: D = None
        self.w: C = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

g = A("g")
c = B("c")
d = C("d")
k = D("k")
n = E("n")
l = F("l")
h = G("h")
e = H("e")

g.p = h
g.r = c
c.v = e
d.v = e
k.p = n
k.q = d
n.w = g
n.t = g
n.p = e
n.o = e
n.q = l
l.u = d
l.v = e
l.t = e
l.x = h
h.v = l
h.r = c
h.p = n
h.x = d
h.w = d
h.q = e
h.t = k
e.x = g
assert g.p.t.q.v.x.txt == "g"