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

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

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

i = A("i")
m = B("m")
l = C("l")
b = C("b")
e = C("e")
n = A("n")
k = B("k")
g = A("g")
c = B("c")

i.y = c
m.r = g
m.v = i
l.w = b
l.q = e
b.w = e
b.q = e
e.w = l
e.q = l
n.y = c
k.r = i
k.v = n
g.y = k
c.r = n
c.v = n
assert c.r.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
l = C("l")
b = C("b")
e = C("e")
n = A("n")
k = B("k")
g = A("g")
c = B("c")

i.y = c
m.r = g
m.v = i
l.w = b
l.q = e
b.w = e
b.q = e
e.w = l
e.q = l
n.y = c
k.r = i
k.v = n
g.y = k
c.r = n
c.v = n
assert c.r.y.v.txt == "n"