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

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

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

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

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

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

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

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

k.y = j
e.x = i
e.w = j
e.y = a
h.q = l
h.r = a
j.q = e
j.r = l
a.x = i
a.w = j
a.y = e
c.y = h
l.x = a
l.w = h
l.y = e
b.y = h
i.x = a
i.w = j
i.y = e
assert i.y.x.y.x.y.x.w.r.w.txt == "h"