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

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

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

f = A("f")
m = B("m")
e = C("e")
l = C("l")
i = A("i")
c = C("c")

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

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

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

f = A("f")
m = B("m")
e = C("e")
l = C("l")
i = A("i")
c = C("c")

f.q = m
f.w = i
f.v = i
m.r = f
m.t = c
e.u = f
l.u = i
i.q = m
i.w = f
i.v = f
c.u = f
assert i.v.q.r.q.t.txt == "c"