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

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

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

f = A("f")
e = B("e")
k = C("k")
i = A("i")
l = B("l")

f.o = i
f.q = k
e.o = f
e.p = l
e.s = k
k.t = i
k.v = f
i.o = f
i.q = k
l.o = f
l.p = e
l.s = k
assert f.o.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
k = C("k")
i = A("i")
l = B("l")

f.o = i
f.q = k
e.o = f
e.p = l
e.s = k
k.t = i
k.v = f
i.o = f
i.q = k
l.o = f
l.p = e
l.s = k
assert f.o.q.t.q.txt == "k"