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

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

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

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

f.p = j
f.y = j
f.w = d
d.q = f
d.u = f
d.y = j
j.z = d
assert j.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: B = None
        self.y: C = None
        self.txt = txt

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

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

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

f.p = j
f.y = j
f.w = d
d.q = f
d.u = f
d.y = j
j.z = d
assert j.z.y.z.txt == "d"