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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: E = None
        self.u: G = None
        self.x: E = None
        self.s: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: H = None
        self.y: G = None
        self.s: I = None
        self.r: A = None
        self.q: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
f = D("f")
h = E("h")
n = F("n")
b = G("b")
c = H("c")
e = I("e")

g.p = b
g.u = c
i.q = b
m.r = i
m.q = h
m.x = h
m.u = b
m.s = f
f.w = m
f.x = h
h.w = c
h.y = b
h.s = e
h.r = g
h.q = g
h.p = f
n.x = f
b.r = f
b.o = h
b.x = n
b.z = n
b.q = g
c.q = i
c.v = b
c.p = e
e.x = g
assert e.x.p.r.x.q.p.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: G = None
        self.u: H = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: E = None
        self.u: G = None
        self.x: E = None
        self.s: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: H = None
        self.y: G = None
        self.s: I = None
        self.r: A = None
        self.q: A = None
        self.p: D = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
f = D("f")
h = E("h")
n = F("n")
b = G("b")
c = H("c")
e = I("e")

g.p = b
g.u = c
i.q = b
m.r = i
m.q = h
m.x = h
m.u = b
m.s = f
f.w = m
f.x = h
h.w = c
h.y = b
h.s = e
h.r = g
h.q = g
h.p = f
n.x = f
b.r = f
b.o = h
b.x = n
b.z = n
b.q = g
c.q = i
c.v = b
c.p = e
e.x = g
assert e.x.p.r.x.q.p.x.x.txt == "f"