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

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

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

i = A("i")
l = B("l")
c = C("c")
f = B("f")
j = A("j")

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

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

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

i = A("i")
l = B("l")
c = C("c")
f = B("f")
j = A("j")

i.v = l
l.r = f
l.w = f
l.u = j
c.q = j
c.w = f
c.y = i
f.r = l
f.w = l
f.u = j
j.v = f
assert l.u.v.u.v.txt == "f"