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

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

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

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

a.r = i
a.p = i
a.v = e
e.y = i
e.r = i
i.y = e
i.z = e
i.w = k
g.r = i
g.p = i
g.v = e
k.y = e
k.z = e
k.w = i
j.r = i
j.p = i
j.v = e
c.r = i
c.p = k
c.v = e
assert a.p.w.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.p: C = None
        self.v: B = None
        self.txt = txt

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

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

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

a.r = i
a.p = i
a.v = e
e.y = i
e.r = i
i.y = e
i.z = e
i.w = k
g.r = i
g.p = i
g.v = e
k.y = e
k.z = e
k.w = i
j.r = i
j.p = i
j.v = e
c.r = i
c.p = k
c.v = e
assert a.p.w.y.r.txt == "i"