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

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

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

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

f.s = g
j.p = f
e.y = f
e.s = f
d.p = f
g.p = f
assert j.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

f.s = g
j.p = f
e.y = f
e.s = f
d.p = f
g.p = f
assert j.p.s.p.s.txt == "g"