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

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.r: B = None
        self.w: G = None
        self.t: F = None
        self.z: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: F = None
        self.o: F = None
        self.y: B = None
        self.s: C = None
        self.v: B = None
        self.t: D = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
g = C("g")
c = D("c")
m = E("m")
d = F("d")
n = G("n")
j = H("j")

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.r: B = None
        self.w: G = None
        self.t: F = None
        self.z: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: F = None
        self.o: F = None
        self.y: B = None
        self.s: C = None
        self.v: B = None
        self.t: D = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
g = C("g")
c = D("c")
m = E("m")
d = F("d")
n = G("n")
j = H("j")

a.p = d
f.o = c
g.s = c
g.t = a
g.v = n
g.w = d
c.u = m
c.r = f
c.w = n
c.t = d
c.z = d
m.x = a
m.w = d
m.o = d
m.y = f
m.v = f
m.s = g
m.t = c
d.y = g
n.o = a
j.x = g
j.w = g
j.z = f
assert n.o.p.y.v.o.p.y.txt == "g"