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

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

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

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

f = A("f")
j = B("j")
k = C("k")
i = D("i")
b = A("b")
g = A("g")
a = B("a")

f.r = i
f.u = i
j.q = b
k.s = a
i.u = b
i.x = b
i.t = a
i.s = j
b.r = i
b.u = i
g.r = i
g.u = i
a.q = b
assert j.q.r.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
k = C("k")
i = D("i")
b = A("b")
g = A("g")
a = B("a")

f.r = i
f.u = i
j.q = b
k.s = a
i.u = b
i.x = b
i.t = a
i.s = j
b.r = i
b.u = i
g.r = i
g.u = i
a.q = b
assert j.q.r.t.q.txt == "b"