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

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

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

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

a.t = l
a.s = d
j.p = l
h.q = b
h.v = j
d.t = b
d.s = a
k.p = l
l.q = b
l.v = k
b.q = l
b.v = k
c.q = l
c.v = k
assert k.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

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

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

a.t = l
a.s = d
j.p = l
h.q = b
h.v = j
d.t = b
d.s = a
k.p = l
l.q = b
l.v = k
b.q = l
b.v = k
c.q = l
c.v = k
assert k.p.q.q.txt == "l"