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

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

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

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

i.p = d
i.t = g
j.r = b
j.v = b
j.p = n
f.t = j
b.r = j
b.v = j
b.p = n
g.p = d
g.t = i
d.p = i
d.t = i
n.t = b
assert b.p.t.v.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: A = None
        self.txt = txt

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

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

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

i.p = d
i.t = g
j.r = b
j.v = b
j.p = n
f.t = j
b.r = j
b.v = j
b.p = n
g.p = d
g.t = i
d.p = i
d.t = i
n.t = b
assert b.p.t.v.p.t.txt == "b"