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

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

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

f = A("f")
d = B("d")
c = C("c")
j = B("j")

f.o = c
f.w = c
d.s = c
d.x = c
c.p = d
j.s = c
j.x = c
assert c.p.s.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
c = C("c")
j = B("j")

f.o = c
f.w = c
d.s = c
d.x = c
c.p = d
j.s = c
j.x = c
assert c.p.s.p.x.txt == "c"