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

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

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

l = A("l")
i = B("i")
k = C("k")
n = A("n")
c = B("c")

l.u = c
l.v = i
i.r = l
i.u = k
k.x = c
k.p = c
n.u = c
n.v = i
c.r = n
c.u = k
assert k.p.r.u.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
k = C("k")
n = A("n")
c = B("c")

l.u = c
l.v = i
i.r = l
i.u = k
k.x = c
k.p = c
n.u = c
n.v = i
c.r = n
c.u = k
assert k.p.r.u.u.p.txt == "c"