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

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

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

l = A("l")
e = B("e")
h = C("h")
b = B("b")
f = B("f")
k = B("k")
n = C("n")

l.x = b
e.x = f
e.u = n
e.r = l
h.q = k
h.u = k
b.x = e
b.u = h
b.r = l
f.x = e
f.u = h
f.r = l
k.x = e
k.u = h
k.r = l
n.q = f
n.u = f
assert b.x.r.x.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
e = B("e")
h = C("h")
b = B("b")
f = B("f")
k = B("k")
n = C("n")

l.x = b
e.x = f
e.u = n
e.r = l
h.q = k
h.u = k
b.x = e
b.u = h
b.r = l
f.x = e
f.u = h
f.r = l
k.x = e
k.u = h
k.r = l
n.q = f
n.u = f
assert b.x.r.x.x.u.q.txt == "f"