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

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

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

g = A("g")
a = B("a")
i = C("i")
m = B("m")
e = C("e")
n = C("n")
b = A("b")

g.r = b
g.z = e
g.x = m
a.v = g
a.p = m
i.t = e
m.v = g
m.p = a
e.t = n
n.t = e
b.r = g
b.z = n
b.x = m
assert e.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.x: B = None
        self.txt = txt

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

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

g = A("g")
a = B("a")
i = C("i")
m = B("m")
e = C("e")
n = C("n")
b = A("b")

g.r = b
g.z = e
g.x = m
a.v = g
a.p = m
i.t = e
m.v = g
m.p = a
e.t = n
n.t = e
b.r = g
b.z = n
b.x = m
assert e.t.t.t.t.t.t.txt == "e"