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

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

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

l = A("l")
j = B("j")
e = C("e")
c = B("c")
g = B("g")

l.y = e
j.t = c
j.p = g
e.r = j
e.w = l
e.s = g
c.t = j
c.p = g
g.t = c
g.p = j
assert e.s.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
e = C("e")
c = B("c")
g = B("g")

l.y = e
j.t = c
j.p = g
e.r = j
e.w = l
e.s = g
c.t = j
c.p = g
g.t = c
g.p = j
assert e.s.t.p.t.p.txt == "g"