class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: 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.x: A = None
        self.t: A = None
        self.w: A = None
        self.txt = txt

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

l.q = j
l.y = h
h.v = j
g.x = k
g.t = l
g.w = l
j.x = l
j.t = l
j.w = l
k.q = j
k.y = h
assert j.x.y.v.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: 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.x: A = None
        self.t: A = None
        self.w: A = None
        self.txt = txt

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

l.q = j
l.y = h
h.v = j
g.x = k
g.t = l
g.w = l
j.x = l
j.t = l
j.w = l
k.q = j
k.y = h
assert j.x.y.v.x.y.txt == "h"