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

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

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

b = A("b")
g = B("g")
i = C("i")
c = A("c")
h = B("h")
m = B("m")
e = A("e")

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

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

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

b = A("b")
g = B("g")
i = C("i")
c = A("c")
h = B("h")
m = B("m")
e = A("e")

b.x = i
b.t = e
b.r = e
g.z = c
g.r = b
g.v = h
i.t = g
i.z = g
c.x = i
c.t = e
c.r = b
h.z = e
h.r = c
h.v = m
m.z = b
m.r = c
m.v = h
e.x = i
e.t = b
e.r = b
assert g.z.r.x.z.v.r.t.txt == "e"