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

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

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

e = A("e")
g = B("g")
n = C("n")
f = B("f")
a = C("a")
l = B("l")
m = C("m")
b = A("b")
h = C("h")

e.r = b
g.s = b
g.t = m
n.t = f
f.s = b
f.t = a
a.t = g
l.s = e
l.t = m
m.t = l
b.r = e
h.t = g
assert e.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
n = C("n")
f = B("f")
a = C("a")
l = B("l")
m = C("m")
b = A("b")
h = C("h")

e.r = b
g.s = b
g.t = m
n.t = f
f.s = b
f.t = a
a.t = g
l.s = e
l.t = m
m.t = l
b.r = e
h.t = g
assert e.r.r.r.txt == "b"