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

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

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

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

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

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

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

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

e.r = j
e.w = h
k.r = j
k.y = e
b.p = c
b.t = h
b.x = k
j.r = e
j.w = i
h.p = c
h.t = i
h.x = k
g.p = c
g.t = h
g.x = k
i.p = c
i.t = g
i.x = k
c.r = e
c.w = g
assert i.x.y.w.p.w.p.w.p.txt == "c"