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

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

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

d = A("d")
h = B("h")
b = C("b")
e = B("e")
c = C("c")

d.q = c
d.o = c
h.v = c
h.p = d
b.v = c
b.p = e
e.v = b
e.p = d
c.v = b
c.p = h
assert h.p.o.p.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
b = C("b")
e = B("e")
c = C("c")

d.q = c
d.o = c
h.v = c
h.p = d
b.v = c
b.p = e
e.v = b
e.p = d
c.v = b
c.p = h
assert h.p.o.p.v.v.txt == "b"