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

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

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

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

g.r = f
j.s = i
k.t = h
i.s = f
e.t = h
d.s = j
c.t = g
h.r = f
f.s = i
assert f.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

g.r = f
j.s = i
k.t = h
i.s = f
e.t = h
d.s = j
c.t = g
h.r = f
f.s = i
assert f.s.s.s.s.txt == "f"