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

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

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

d = A("d")
a = B("a")
h = C("h")
n = A("n")
b = C("b")
j = B("j")
g = B("g")
f = C("f")
l = B("l")
e = B("e")

d.o = a
a.o = b
h.r = j
h.v = a
h.p = d
n.o = j
b.r = a
b.v = j
b.p = d
j.o = f
g.o = f
f.r = a
f.v = j
f.p = d
l.o = h
e.o = f
assert d.o.o.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
h = C("h")
n = A("n")
b = C("b")
j = B("j")
g = B("g")
f = C("f")
l = B("l")
e = B("e")

d.o = a
a.o = b
h.r = j
h.v = a
h.p = d
n.o = j
b.r = a
b.v = j
b.p = d
j.o = f
g.o = f
f.r = a
f.v = j
f.p = d
l.o = h
e.o = f
assert d.o.o.p.o.o.txt == "b"