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

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

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

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

e.u = f
e.s = j
k.x = a
j.t = c
j.p = c
j.y = f
a.x = k
c.t = j
c.p = j
c.y = f
f.u = e
f.s = c
assert c.y.s.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: C = None
        self.txt = txt

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

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

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

e.u = f
e.s = j
k.x = a
j.t = c
j.p = c
j.y = f
a.x = k
c.t = j
c.p = j
c.y = f
f.u = e
f.s = c
assert c.y.s.t.p.txt == "c"