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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: G = None
        self.r: G = None
        self.o: D = None
        self.w: G = None
        self.txt = txt

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

h = A("h")
a = B("a")
b = C("b")
g = D("g")
f = E("f")
j = F("j")
m = G("m")

h.x = a
a.x = g
b.r = h
b.w = a
b.z = j
b.t = j
b.v = m
g.q = j
g.y = b
g.p = h
f.w = m
f.q = b
f.y = b
j.s = h
j.x = m
j.r = m
j.w = m
j.o = g
m.w = a
m.y = a
m.q = f
m.v = b
assert g.y.w.x.p.x.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: G = None
        self.r: G = None
        self.o: D = None
        self.w: G = None
        self.txt = txt

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

h = A("h")
a = B("a")
b = C("b")
g = D("g")
f = E("f")
j = F("j")
m = G("m")

h.x = a
a.x = g
b.r = h
b.w = a
b.z = j
b.t = j
b.v = m
g.q = j
g.y = b
g.p = h
f.w = m
f.q = b
f.y = b
j.s = h
j.x = m
j.r = m
j.w = m
j.o = g
m.w = a
m.y = a
m.q = f
m.v = b
assert g.y.w.x.p.x.x.p.txt == "h"