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

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

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

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

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

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

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

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

i.p = n
f.v = i
f.u = g
j.s = i
g.s = n
n.p = i
b.v = i
b.u = j
assert b.u.s.p.p.txt == "i"