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

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

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

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

e.w = i
e.q = l
e.o = j
f.p = h
f.q = e
i.z = j
j.w = i
j.q = h
j.o = e
b.p = h
b.q = j
h.p = l
h.q = e
l.p = f
l.q = e
assert b.p.q.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: B = None
        self.o: A = None
        self.txt = txt

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

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

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

e.w = i
e.q = l
e.o = j
f.p = h
f.q = e
i.z = j
j.w = i
j.q = h
j.o = e
b.p = h
b.q = j
h.p = l
h.q = e
l.p = f
l.q = e
assert b.p.q.q.p.txt == "f"