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

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

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

f = A("f")
k = B("k")
i = C("i")
d = C("d")
b = A("b")
h = C("h")

f.o = k
f.q = k
f.u = b
k.q = b
i.p = k
i.u = f
d.p = k
d.u = b
b.o = k
b.q = k
b.u = f
h.p = k
h.u = b
assert i.p.q.o.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: B = None
        self.u: A = None
        self.txt = txt

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

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

f = A("f")
k = B("k")
i = C("i")
d = C("d")
b = A("b")
h = C("h")

f.o = k
f.q = k
f.u = b
k.q = b
i.p = k
i.u = f
d.p = k
d.u = b
b.o = k
b.q = k
b.u = f
h.p = k
h.u = b
assert i.p.q.o.q.u.q.txt == "k"