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

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

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

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

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

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

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

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

j.r = c
g.x = c
g.s = m
g.t = m
e.y = j
e.z = i
h.r = c
i.r = e
m.x = c
m.s = g
m.t = g
c.y = k
c.z = k
k.r = c
assert i.r.z.r.y.txt == "j"