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

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

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

c = A("c")
h = B("h")
k = C("k")
l = A("l")
j = C("j")

c.p = l
c.u = h
h.v = j
k.r = j
k.q = l
k.t = h
l.p = c
l.u = h
j.r = k
j.q = l
j.t = h
assert h.v.q.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: B = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
k = C("k")
l = A("l")
j = C("j")

c.p = l
c.u = h
h.v = j
k.r = j
k.q = l
k.t = h
l.p = c
l.u = h
j.r = k
j.q = l
j.t = h
assert h.v.q.p.u.txt == "h"