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

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

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

g = A("g")
m = B("m")
l = C("l")
i = A("i")
j = B("j")

g.y = i
m.q = l
m.r = j
m.v = j
l.u = j
i.y = g
j.q = l
j.r = m
j.v = m
assert g.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
l = C("l")
i = A("i")
j = B("j")

g.y = i
m.q = l
m.r = j
m.v = j
l.u = j
i.y = g
j.q = l
j.r = m
j.v = m
assert g.y.y.y.txt == "i"