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

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

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

j = A("j")
c = B("c")
f = C("f")
i = C("i")
n = C("n")

j.p = c
j.y = c
c.y = f
c.s = j
f.z = n
f.v = n
f.x = j
i.z = n
i.v = n
i.x = j
n.z = i
n.v = i
n.x = j
assert f.x.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
f = C("f")
i = C("i")
n = C("n")

j.p = c
j.y = c
c.y = f
c.s = j
f.z = n
f.v = n
f.x = j
i.z = n
i.v = n
i.x = j
n.z = i
n.v = i
n.x = j
assert f.x.p.y.txt == "f"