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

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

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

j = A("j")
d = B("d")
b = C("b")
g = B("g")
k = C("k")
l = A("l")
i = B("i")

j.x = k
d.q = i
d.s = l
b.u = j
g.q = i
g.s = j
k.u = j
l.x = b
i.q = d
i.s = l
assert j.x.u.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
b = C("b")
g = B("g")
k = C("k")
l = A("l")
i = B("i")

j.x = k
d.q = i
d.s = l
b.u = j
g.q = i
g.s = j
k.u = j
l.x = b
i.q = d
i.s = l
assert j.x.u.x.u.x.u.txt == "j"