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

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

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

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

d.o = j
d.t = n
a.o = i
a.y = n
a.r = h
h.t = j
h.r = g
h.q = g
i.o = a
i.y = j
i.r = h
n.t = j
n.r = g
n.q = d
j.t = n
j.r = d
j.q = d
g.o = n
g.t = h
assert i.y.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: C = None
        self.txt = txt

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

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

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

d.o = j
d.t = n
a.o = i
a.y = n
a.r = h
h.t = j
h.r = g
h.q = g
i.o = a
i.y = j
i.r = h
n.t = j
n.r = g
n.q = d
j.t = n
j.r = d
j.q = d
g.o = n
g.t = h
assert i.y.t.r.t.r.txt == "g"