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

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

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

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

g.p = b
g.x = i
g.y = i
b.r = g
a.s = j
a.w = j
a.u = c
i.p = c
i.x = g
i.y = g
c.r = g
j.s = a
j.w = a
j.u = b
assert g.p.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: A = None
        self.y: A = None
        self.txt = txt

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

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

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

g.p = b
g.x = i
g.y = i
b.r = g
a.s = j
a.w = j
a.u = c
i.p = c
i.x = g
i.y = g
c.r = g
j.s = a
j.w = a
j.u = b
assert g.p.r.y.txt == "i"