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

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

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

i = A("i")
n = B("n")
b = C("b")
f = C("f")
k = A("k")
j = B("j")
m = B("m")
d = C("d")

i.s = k
n.u = f
n.t = b
n.q = m
b.x = f
f.x = b
k.s = i
j.u = d
j.t = d
j.q = n
m.u = d
m.t = b
m.q = n
d.x = b
assert j.u.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
b = C("b")
f = C("f")
k = A("k")
j = B("j")
m = B("m")
d = C("d")

i.s = k
n.u = f
n.t = b
n.q = m
b.x = f
f.x = b
k.s = i
j.u = d
j.t = d
j.q = n
m.u = d
m.t = b
m.q = n
d.x = b
assert j.u.x.x.x.txt == "b"