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

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

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

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

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

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

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

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

b.r = g
c.u = g
i.y = h
g.y = h
j.u = i
h.u = i
k.y = c
assert b.r.y.u.y.u.txt == "i"