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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: C = None
        self.txt = txt

d = A("d")
h = B("h")
c = C("c")
j = C("j")
g = C("g")
k = C("k")
n = A("n")
a = A("a")
b = B("b")

d.s = a
d.t = b
h.y = b
h.s = j
h.t = n
c.o = d
c.w = k
j.o = n
j.w = c
g.o = n
g.w = j
k.o = a
k.w = c
n.s = a
n.t = b
a.s = d
a.t = b
b.y = h
b.s = g
b.t = d
assert b.t.t.t.t.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: C = None
        self.txt = txt

d = A("d")
h = B("h")
c = C("c")
j = C("j")
g = C("g")
k = C("k")
n = A("n")
a = A("a")
b = B("b")

d.s = a
d.t = b
h.y = b
h.s = j
h.t = n
c.o = d
c.w = k
j.o = n
j.w = c
g.o = n
g.w = j
k.o = a
k.w = c
n.s = a
n.t = b
a.s = d
a.t = b
b.y = h
b.s = g
b.t = d
assert b.t.t.t.t.y.y.txt == "b"