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

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

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

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

g.r = k
c.w = e
c.r = i
c.q = g
a.y = e
a.r = i
a.u = h
e.y = h
e.u = h
e.r = i
i.w = a
i.r = c
i.q = k
k.r = g
h.y = e
h.r = i
h.u = a
assert a.y.u.r.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

g.r = k
c.w = e
c.r = i
c.q = g
a.y = e
a.r = i
a.u = h
e.y = h
e.u = h
e.r = i
i.w = a
i.r = c
i.q = k
k.r = g
h.y = e
h.r = i
h.u = a
assert a.y.u.r.q.r.txt == "g"