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

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

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

c = A("c")
b = B("b")
i = C("i")
j = C("j")

c.y = i
b.r = c
b.t = c
i.p = c
j.p = c
assert i.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
i = C("i")
j = C("j")

c.y = i
b.r = c
b.t = c
i.p = c
j.p = c
assert i.p.y.p.y.txt == "i"