class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: C = None
        self.q: B = 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.v: B = None
        self.txt = txt

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

g.x = i
g.v = i
g.q = l
l.u = i
i.v = l
assert i.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: C = None
        self.q: B = 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.v: B = None
        self.txt = txt

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

g.x = i
g.v = i
g.q = l
l.u = i
i.v = l
assert i.v.u.v.txt == "l"