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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: A = None
        self.x: F = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: D = None
        self.y: A = None
        self.p: G = None
        self.x: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: G = None
        self.o: D = None
        self.w: C = None
        self.t: C = None
        self.y: G = None
        self.txt = txt

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

g = A("g")
e = B("e")
k = C("k")
i = D("i")
n = E("n")
a = F("a")
f = G("f")

g.x = n
e.t = i
e.q = g
e.o = g
e.x = a
k.u = f
i.x = f
i.o = f
i.p = g
n.u = a
n.z = i
n.y = g
n.x = g
n.p = f
a.z = f
a.y = f
a.o = i
a.w = k
a.t = k
f.z = g
f.t = i
f.w = a
assert n.x.x.p.z.x.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: A = None
        self.x: F = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: D = None
        self.y: A = None
        self.p: G = None
        self.x: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: G = None
        self.o: D = None
        self.w: C = None
        self.t: C = None
        self.y: G = None
        self.txt = txt

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

g = A("g")
e = B("e")
k = C("k")
i = D("i")
n = E("n")
a = F("a")
f = G("f")

g.x = n
e.t = i
e.q = g
e.o = g
e.x = a
k.u = f
i.x = f
i.o = f
i.p = g
n.u = a
n.z = i
n.y = g
n.x = g
n.p = f
a.z = f
a.y = f
a.o = i
a.w = k
a.t = k
f.z = g
f.t = i
f.w = a
assert n.x.x.p.z.x.z.p.txt == "g"