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

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

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

i = A("i")
j = B("j")
a = C("a")
b = A("b")
l = C("l")
k = B("k")
h = C("h")
f = B("f")

i.y = k
i.x = k
i.q = l
j.t = a
j.y = i
a.v = b
b.y = j
b.x = f
b.q = l
l.v = b
k.t = a
k.y = i
h.v = b
f.t = a
f.y = b
assert k.t.v.q.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: B = None
        self.q: C = None
        self.txt = txt

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

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

i = A("i")
j = B("j")
a = C("a")
b = A("b")
l = C("l")
k = B("k")
h = C("h")
f = B("f")

i.y = k
i.x = k
i.q = l
j.t = a
j.y = i
a.v = b
b.y = j
b.x = f
b.q = l
l.v = b
k.t = a
k.y = i
h.v = b
f.t = a
f.y = b
assert k.t.v.q.v.x.txt == "f"