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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: H = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: F = None
        self.x: A = None
        self.r: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.z: H = None
        self.w: H = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: B = None
        self.v: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: B = None
        self.s: E = None
        self.w: F = None
        self.y: G = None
        self.r: G = None
        self.o: E = None
        self.t: F = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: H = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: F = None
        self.x: A = None
        self.r: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.z: H = None
        self.w: H = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: B = None
        self.v: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: B = None
        self.s: E = None
        self.w: F = None
        self.y: G = None
        self.r: G = None
        self.o: E = None
        self.t: F = None
        self.txt = txt

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

g.r = c
a.x = d
a.t = d
a.p = h
d.z = c
d.x = g
d.r = g
b.s = g
b.y = c
b.x = m
i.t = a
i.x = a
i.z = h
i.w = h
c.p = g
c.z = a
c.v = a
m.q = a
h.u = g
h.q = a
h.s = i
h.o = i
h.w = c
h.t = c
h.y = m
h.r = m
assert g.r.z.p.q.x.x.r.txt == "c"