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

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

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

d = A("d")
f = B("f")
e = C("e")
n = A("n")
j = C("j")
m = B("m")
b = A("b")

d.o = e
d.t = m
f.v = b
f.p = m
e.p = f
e.o = m
e.t = d
n.o = e
n.t = f
j.p = f
j.o = f
j.t = d
m.v = d
m.p = f
b.o = j
b.t = f
assert f.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
e = C("e")
n = A("n")
j = C("j")
m = B("m")
b = A("b")

d.o = e
d.t = m
f.v = b
f.p = m
e.p = f
e.o = m
e.t = d
n.o = e
n.t = f
j.p = f
j.o = f
j.t = d
m.v = d
m.p = f
b.o = j
b.t = f
assert f.p.p.p.p.txt == "f"