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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: G = None
        self.o: G = None
        self.x: B = None
        self.z: G = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: B = None
        self.q: A = None
        self.t: C = None
        self.s: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: D = None
        self.r: B = None
        self.q: A = None
        self.u: A = None
        self.v: C = None
        self.o: B = None
        self.txt = txt

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

d = A("d")
h = B("h")
g = C("g")
k = D("k")
f = E("f")
b = F("b")
e = G("e")

d.y = g
d.r = g
h.r = g
g.z = b
k.u = d
k.v = d
k.s = e
k.o = e
k.z = e
k.x = h
f.v = k
f.z = h
f.q = d
f.s = d
f.t = g
b.t = k
b.y = k
b.r = h
b.o = h
b.q = d
b.u = d
b.v = g
e.r = g
e.u = b
e.x = h
e.w = f
assert k.x.r.z.y.z.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: G = None
        self.o: G = None
        self.x: B = None
        self.z: G = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: B = None
        self.q: A = None
        self.t: C = None
        self.s: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: D = None
        self.r: B = None
        self.q: A = None
        self.u: A = None
        self.v: C = None
        self.o: B = None
        self.txt = txt

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

d = A("d")
h = B("h")
g = C("g")
k = D("k")
f = E("f")
b = F("b")
e = G("e")

d.y = g
d.r = g
h.r = g
g.z = b
k.u = d
k.v = d
k.s = e
k.o = e
k.z = e
k.x = h
f.v = k
f.z = h
f.q = d
f.s = d
f.t = g
b.t = k
b.y = k
b.r = h
b.o = h
b.q = d
b.u = d
b.v = g
e.r = g
e.u = b
e.x = h
e.w = f
assert k.x.r.z.y.z.x.r.txt == "g"