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

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

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

e = A("e")
b = B("b")
c = C("c")
n = B("n")
d = A("d")
f = C("f")
g = A("g")
h = B("h")
k = B("k")

e.y = k
b.q = k
b.r = e
c.y = b
c.x = n
c.s = k
n.q = b
n.r = d
d.y = n
f.y = k
f.x = h
f.s = b
g.y = n
h.q = k
h.r = e
k.q = b
k.r = g
assert k.r.y.r.y.r.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
c = C("c")
n = B("n")
d = A("d")
f = C("f")
g = A("g")
h = B("h")
k = B("k")

e.y = k
b.q = k
b.r = e
c.y = b
c.x = n
c.s = k
n.q = b
n.r = d
d.y = n
f.y = k
f.x = h
f.s = b
g.y = n
h.q = k
h.r = e
k.q = b
k.r = g
assert k.r.y.r.y.r.y.q.txt == "b"