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

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

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

g = A("g")
k = B("k")
a = C("a")
d = A("d")
i = B("i")
j = C("j")
f = A("f")
h = C("h")

g.r = k
k.x = i
k.q = a
a.t = j
a.y = h
d.r = k
i.x = k
i.q = j
j.t = h
j.y = h
f.r = i
h.t = a
h.y = j
assert j.t.y.t.t.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
a = C("a")
d = A("d")
i = B("i")
j = C("j")
f = A("f")
h = C("h")

g.r = k
k.x = i
k.q = a
a.t = j
a.y = h
d.r = k
i.x = k
i.q = j
j.t = h
j.y = h
f.r = i
h.t = a
h.y = j
assert j.t.y.t.t.y.y.y.y.txt == "j"