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

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

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

g = A("g")
b = B("b")
j = C("j")
l = B("l")
f = C("f")
c = B("c")

g.s = f
g.w = j
b.x = g
b.p = g
j.x = g
j.r = c
j.v = f
l.x = g
l.p = g
f.x = g
f.r = l
f.v = j
c.x = g
c.p = g
assert j.r.p.s.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
j = C("j")
l = B("l")
f = C("f")
c = B("c")

g.s = f
g.w = j
b.x = g
b.p = g
j.x = g
j.r = c
j.v = f
l.x = g
l.p = g
f.x = g
f.r = l
f.v = j
c.x = g
c.p = g
assert j.r.p.s.v.v.txt == "f"