class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.r: 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.r: B = None
        self.u: A = None
        self.txt = txt

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

g.p = b
g.o = d
g.r = j
b.v = g
b.p = n
e.r = d
e.u = g
d.v = f
d.p = b
f.p = b
f.r = b
f.o = d
j.v = f
j.p = b
n.v = f
n.p = j
assert e.r.v.r.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.r: 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.r: B = None
        self.u: A = None
        self.txt = txt

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

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