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

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

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

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

c.y = j
c.q = f
c.r = a
f.q = j
f.v = j
f.y = j
j.t = f
j.y = f
a.y = j
a.q = f
a.r = c
assert j.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: B = None
        self.r: A = None
        self.txt = txt

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

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

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

c.y = j
c.q = f
c.r = a
f.q = j
f.v = j
f.y = j
j.t = f
j.y = f
a.y = j
a.q = f
a.r = c
assert j.y.y.y.txt == "f"