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

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

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

l = A("l")
m = B("m")
b = C("b")
f = A("f")
h = C("h")
i = B("i")

l.y = m
m.q = l
m.r = l
m.v = i
b.t = m
b.y = m
b.q = h
f.y = i
h.t = m
h.q = b
h.y = i
i.q = f
i.r = f
i.v = m
assert h.q.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
b = C("b")
f = A("f")
h = C("h")
i = B("i")

l.y = m
m.q = l
m.r = l
m.v = i
b.t = m
b.y = m
b.q = h
f.y = i
h.t = m
h.q = b
h.y = i
i.q = f
i.r = f
i.v = m
assert h.q.q.y.txt == "i"