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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.x: G = None
        self.v: D = None
        self.p: C = None
        self.txt = txt

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

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

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

k.o = i
k.p = m
g.x = e
g.z = e
g.u = d
g.r = i
e.r = i
e.w = d
f.t = g
f.z = g
f.r = e
d.t = k
d.x = m
d.v = f
d.p = e
i.z = f
i.y = m
i.o = g
i.t = e
m.y = e
assert g.r.z.z.u.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.p: G = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.x: G = None
        self.v: D = None
        self.p: C = None
        self.txt = txt

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

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

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

k.o = i
k.p = m
g.x = e
g.z = e
g.u = d
g.r = i
e.r = i
e.w = d
f.t = g
f.z = g
f.r = e
d.t = k
d.x = m
d.v = f
d.p = e
i.z = f
i.y = m
i.o = g
i.t = e
m.y = e
assert g.r.z.z.u.v.r.txt == "e"