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

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

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

l = A("l")
e = B("e")
i = C("i")
b = B("b")
f = A("f")
c = B("c")
j = B("j")

l.q = e
l.z = f
l.s = i
e.r = f
e.x = f
e.t = l
i.r = l
i.z = c
b.r = f
b.t = f
b.x = l
f.q = c
f.z = l
f.s = i
c.r = l
c.x = l
c.t = f
j.r = l
j.x = l
j.t = l
assert l.q.x.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.s: C = None
        self.txt = txt

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

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

l = A("l")
e = B("e")
i = C("i")
b = B("b")
f = A("f")
c = B("c")
j = B("j")

l.q = e
l.z = f
l.s = i
e.r = f
e.x = f
e.t = l
i.r = l
i.z = c
b.r = f
b.t = f
b.x = l
f.q = c
f.z = l
f.s = i
c.r = l
c.x = l
c.t = f
j.r = l
j.x = l
j.t = l
assert l.q.x.z.q.x.txt == "f"