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

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: B = None
        self.txt = txt

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

j = A("j")
i = B("i")
l = C("l")
h = B("h")
g = A("g")
c = A("c")

j.r = c
j.y = h
i.o = c
i.u = h
l.s = c
l.q = i
h.o = j
h.u = i
g.r = c
g.y = i
c.r = g
c.y = h
assert g.r.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: B = None
        self.txt = txt

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

j = A("j")
i = B("i")
l = C("l")
h = B("h")
g = A("g")
c = A("c")

j.r = c
j.y = h
i.o = c
i.u = h
l.s = c
l.q = i
h.o = j
h.u = i
g.r = c
g.y = i
c.r = g
c.y = h
assert g.r.y.u.txt == "i"