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

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

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

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

m.o = i
f.v = m
f.p = i
f.y = b
j.q = b
j.w = b
j.u = m
i.o = m
b.q = j
b.w = j
b.u = i
l.v = i
l.p = m
l.y = j
assert f.y.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

m.o = i
f.v = m
f.p = i
f.y = b
j.q = b
j.w = b
j.u = m
i.o = m
b.q = j
b.w = j
b.u = i
l.v = i
l.p = m
l.y = j
assert f.y.u.o.txt == "m"